首页 > 编程语言 > 详细

JavaSE---java.util---regex

时间:2020-10-16 20:33:29      阅读:31      评论:0      收藏:0      [点我收藏+]

1、Pattern

    A compiled representation of a regular expression.(一个正则表达式 编译表示

    无公共构造参数,可以通过static方法compile()创建实例

 

Pattern pattern = Pattern.compile("a");

 

 

2、Matcher

    An engine that performs match operations on a {@linkplain java.lang.CharSequence* character sequence} by interpreting a Pattern.(对输入字符串   进行解释和匹配操作的引擎

    无公共构造方法,需要调用 Pattern 对象的 matcher 方法来获得一个 Matcher 对象

 

Matcher matcher = pattern.matcher("cca");

 

     方法:

      public boolean find()    Attempts to find the next subsequence of the input sequence that matches the pattern.(找到匹配正则的字符)

      public Matcher appendReplacement(StringBuffer sb, String replacement)  将匹配正则的字符 用目标字符进行替换

 

JavaSE---java.util---regex

原文:https://www.cnblogs.com/anpeiyong/p/13827448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!