标签:highlight inpu exp lang 构造 通过 ati str 需要
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) 将匹配正则的字符 用目标字符进行替换
标签:highlight inpu exp lang 构造 通过 ati str 需要
原文地址:https://www.cnblogs.com/anpeiyong/p/13827448.html