a- //我我我......我爱爱爱...爱学..学.....编编程.....
- //转为 我爱学编程
- public class Test11 {
- public static void main(String[] args) {
- String str = "我我我......我爱爱爱...爱学..学.....编编程.....";
- //将.替换成空字符
- str = str.replaceAll("\\.", "");
- System.out.println(str);
- //去除叠词
- str = str.replaceAll("(.)\\1+","$1");
- System.out.println(str);
-
- str = "abcabcaaabcaaaabbccabc";
- str = str.replaceAll("(abc(aa))\\1", "*");
- System.out.println(str);
- }
- }
复制代码 |
|