java.util.regex.Matcher.useTransparentBounds(boolean b)
方法設定此匹配器的區域邊界的透明度。
以下是java.util.regex.Matcher.useTransparentBounds(boolean b)
方法的宣告。
public Matcher useTransparentBounds(boolean b)
b
- 指示是否使用透明邊界的布林值。這個匹配。
以下範例顯示了java.util.regex.Matcher.useTransparentBounds(boolean b)
方法的用法。
package com.yiibai;
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) {
// create a pattern
Pattern pattern = Pattern.compile(REGEX);
// get a matcher object
Matcher matcher = pattern.matcher(INPUT);
matcher.useTransparentBounds(true);
System.out.println(matcher.hasTransparentBounds());
}
}
編譯並執行上面的程式,這將產生以下結果 -
true