黑马程序员技术交流社区
标题:
正则表达式练习
[打印本页]
作者:
拾起落叶
时间:
2015-7-14 14:52
标题:
正则表达式练习
public static void main(String[] args) {
String str="我我我我我我...要要要要要要要要要......学学学学学学学.....编编编编编编编...程程程程........";
str=str.replaceAll("\\.+", "");
System.out.println(str);
str=str.replaceAll("(.)\\1+", "$1");
System.out.println(str);
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2