正则表达式的基本使用

匹配的话就是str.matches();

替换的话就是str.replaceall("正则",新的表达式);

查找稍微复杂些,我们需要首先获得Partern对象。这个对象的获取方式是通过Partern p Partern.Complie(Regexp String)

然后获得Matcher m=p.matcher(str);

m.find()返回是否找回数据

m.group()返回找回的数据

至于一些元字符,稍后再总结吧。

原文地址:https://www.cnblogs.com/hysys32/p/6704653.html