Java 正则 中的 Matcher useTransparen

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

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

Matcher useTransparentBounds - 声明

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

Matcher useTransparentBounds - 返回值

这个匹配器。

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

来源:LearnFk无涯教程网

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());
   }
}

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

true

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

技术教程推荐

技术与商业案例解读 -〔徐飞〕

趣谈Linux操作系统 -〔刘超〕

DevOps实战笔记 -〔石雪峰〕

etcd实战课 -〔唐聪〕

MySQL 必知必会 -〔朱晓峰〕

说透5G -〔杨四昌〕

超级访谈:对话张雪峰 -〔张雪峰〕

Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕

React Native 新架构实战课 -〔蒋宏伟〕

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