java.time.Matcher.hasTransparentBounds()範例

2019-10-16 22:19:10

java.time.Matcher.hasTransparentBounds()方法查詢此匹配器的區域邊界的透明度。

宣告

以下是java.time.Matcher.hasTransparentBounds()方法的宣告。

public boolean hasTransparentBounds()

返回值

如果此匹配器使用透明邊界,則返回true,否則返回false

範例

以下範例顯示了java.time.Matcher.hasTransparentBounds()方法的用法。

package com.yiibai;

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("hasTransparentBounds(): " + matcher.hasTransparentBounds());
   }
}

編譯並執行上面的程式,這將產生以下結果 -

hasTransparentBounds(): false