java.util.regex.Matcher.groupCount() 方法



說明

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

宣告

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

public boolean hasTransparentBounds()

返回值

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

範例

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

package com.tutorialspoint;

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
javaregex_matcher.htm
廣告
© . All rights reserved.