码迷,mamicode.com
首页 > 编程语言 > 详细

Java替换中使用正则表达式实现中间模糊匹配

时间:2018-05-09 21:02:24      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:replace   span   字符   string   target   class   正则表达式   表达   blank   

使用“.+?”实现中间模糊匹配的代码:

public class Test {  
  
    public static void main(String[] args) {  
        String str="总会在某一个回眸的时刻醉了流年,濡湿了柔软的心.总会有某一个回眸的时刻醉了流年,濡湿了柔软的心";  
        str=str.replaceAll("总会在.+?流年", "总会有某一个回眸的时刻醉了流年");  
        System.out.println(str);  
    }  
  
} 

注:只能模糊匹配中间不确定的字符串

原文链接

Java替换中使用正则表达式实现中间模糊匹配

标签:replace   span   字符   string   target   class   正则表达式   表达   blank   

原文地址:https://www.cnblogs.com/oskyhg/p/9016165.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!