java.util.regex.Matcher.useAnchoringBounds(boolean b)方法设置此匹配器的区域边界定位。
Matcher useAnchoringBounds - 声明
public Matcher useAnchoringBounds(boolean b)
b - 指示是否使用锚定边界的布尔值。
Matcher useAnchoringBounds - 返回值
这个匹配器。
Matcher useAnchoringBounds - 示例
下面的示例显示java.util.regex.Matcher.useAnchoringBounds(boolean b)方法的用法。
package com.learnfk; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatcherDemo { private static final String REGEX = "(.*)(\\d+)(.*)"; private static final String INPUT = "This is a sample Text, 1234, with numbers in between."; public static void main(String[] args) { //创建一个模式 Pattern pattern = Pattern.compile(REGEX); //获取匹配器对象 Matcher matcher = pattern.matcher(INPUT); matcher.useAnchoringBounds(true); System.out.println(matcher.hasAnchoringBounds()); } }
让无涯教程编译并运行以上程序,这将产生以下输出-
true
参考链接
https://www.learnfk.com/javaregex/javaregex-matcher-useanchoringbounds.html
标签:regex,Java,Matcher,无涯,util,matcher,java,useAnchoringBounds From: https://blog.51cto.com/u_14033984/9049299