Java 正则 中的 Matcher useTransparen

首页 / 正则入门教程 / Java 正则 中的 Matcher useTransparen

java.util.regex.Matcher.useTransparentBounds(boolean b)方法设置此匹配器的区域边界。

Matcher useTransparentBounds - 声明

public Matcher useTransparentBounds(boolean b)
  • b   -  指示是否使用范围的布尔值。

Matcher useTransparentBounds - 返回值

这个匹配器。

Matcher useTransparentBounds - 示例

下面的示例显示java.util.regex.Matcher.useTransparentBounds(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.useTransparentBounds(true);
      System.out.println(matcher.hasTransparentBounds());
   }
}

让无涯教程编译并运行以上程序,这将产生以下输出-

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/javaregex/javaregex-matcher-usetransparentbounds.html

来源:LearnFk无涯教程网

true

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

趣谈网络协议 -〔刘超〕

Vim 实用技巧必知必会 -〔吴咏炜〕

Spark核心原理与实战 -〔王磊〕

Spring编程常见错误50例 -〔傅健〕

性能优化高手课 -〔尉刚强〕

零基础入门Spark -〔吴磊〕

郭东白的架构课 -〔郭东白〕

朱涛 · Kotlin编程第一课 -〔朱涛〕

遗留系统现代化实战 -〔姚琪琳〕

好记忆不如烂笔头。留下您的足迹吧 :)