1. Base character replacement
Requirements:
Replaces a string with a number string in *
String e = "ASDLFJ328238ASLDFJLSFD32323SDFL";
String reg5 = "\\d+";
String newstr = E.replaceall (Reg5, "*");
System.out.println (NEWSTR);
Print Result: ASDLFJ**ASLDFJLSFD**SDFL
2. Replacement of overlapping words
Requirements:
To replace a duplicate string in a string with a *
String f = "ASDLFJCCCASDFZZASFD";
String Reg6 = "(.) \\1+ ";
String newStr2 = F.replaceall (Reg6, "*");
System.out.println (NEWSTR2);
Print Result: ASDLFJ*ASDF*ASFD
3. Special substitutions, based on the substitution of the above overlapping words
Requirements:
A single character that replaces repeated strings in a string with the same character value
String g = "ASDLFJCCCASDFZZASFD";
String Reg7 = "(.) \\1+ ";
String NEWSTR3 = G.replaceall (Reg7, "$"); The values that are filtered by the first group in the regular expression are shown here
System.out.println (NEWSTR3);
Print Results: ASDLFJCASDFZASFD