import java.util.regex.*;
class L
{
public static void main(String args[])
{
checkTel();
}
public static void checkTel()
{
String str="我我。。。。。我要。。。。要要学。。。。学";
str=str.replaceAll("\\。+","");
System.out.println(str);
str=str.replaceAll("(.)\\1+","$1");
System.out.println(str);
}
}正则表达式 替换应用(治疗结巴)
本文探讨了正则表达式在去除多余字符、重复字符等方面的应用,通过实例展示了其在字符串处理中的强大功能。

被折叠的 条评论
为什么被折叠?



