Javaregex-matcher-usetransparentbounds

提供:Dev Guides
移動先:案内検索

Matcher.useTransparentBounds()メソッド

説明

  • 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.finddevguides;

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