目录

boolean hasAnchoringBounds()

描述 (Description)

java.time.Matcher.hasAnchoringBounds()方法查询此匹配器的区域边界的锚定。

声明 (Declaration)

以下是java.time.Matcher.hasAnchoringBounds()方法的声明。

public boolean hasAnchoringBounds()

返回值 (Return Value)

如果此匹配器使用锚定边界,则返回true,否则返回false。

例子 (Example)

以下示例显示了java.time.Matcher.hasAnchoringBounds()方法的用法。

package com.iowiki;
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);
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT);
      System.out.println("hasAnchoringBounds(): " + matcher.hasAnchoringBounds());
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

hasAnchoringBounds(): true
↑回到顶部↑
WIKI教程 @2018