当前位置:主页 > 软件编程 > JAVA代码 >

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

时间:2021-11-04 10:01:51 | 栏目:JAVA代码 | 点击:

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

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

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

您可能感兴趣的文章:

相关文章