java.time.Matcher.hasAnchoringBounds()方法查询此匹配器的区域边界定位。
boolean hasAnchoringBounds() - 声明
以下是 java.time.Matcher.hasAnchoringBounds()方法的声明。
public boolean hasAnchoringBounds()
boolean hasAnchoringBounds() - 返回值
如果此匹配器使用锚定边界,则为true,否则为false。
boolean hasAnchoringBounds() - 示例
以下示例显示java.time.Matcher.hasAnchoringBounds()方法的用法。
package com.learnfk; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatcherDemo { private static String REGEX = "(a*b)(foo)"; private static String INPUT = "aabfooaabfooabfoob"; public static void main(String[] args) { Pattern pattern = Pattern.compile(REGEX); //获取匹配器对象 Matcher matcher = pattern.matcher(INPUT); System.out.println("hasAnchoringBounds(): " + matcher.hasAnchoringBounds()); } }
让无涯教程编译并运行以上程序,这将产生以下输出-
hasAnchoringBounds(): true
参考链接
https://www.learnfk.com/javaregex/javaregex-matcher-hasanchoringbounds.html
标签:java,Pattern,Matcher,无涯,boolean,matcher,Java,hasAnchoringBounds From: https://blog.51cto.com/u_14033984/9041707