使用[.+?]实现中间模糊 匹配 的代码:
1 2 3 4 5 6 7 8 9 |
public class test {
public static void main(string[] args) { string str= "总会在某一个回眸的时刻醉了流年,濡湿了柔软的心.总会有某一个回眸的时刻醉了流年,濡湿了柔软的心" ; str=str.replaceall( "总会在.+?流年" , "总会有某一个回眸的时刻醉了流年" ); system.out.println(str); }
} |
注:只能模糊匹配中间不确定的字符串
以上这篇java替换中使用 正则表达式 实现中间模糊匹配的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
原文链接:https://blog.csdn.net/t0404/article/details/72860091
查看更多关于Java替换中使用正则表达式实现中间模糊匹配的方法的详细内容...