the replaceAll () method uses the given parameters replacement replacement string matches all given regular expression substring.
String replaceAll public (String regex, String Replacement)
regex ---- This string matches regular expression
newChar ---- to replace every occurrence of a string of
successful replacement string is returned, failed to return the original string.
String str = "1234*Aa";
System.out.println(str.replaceAll("\\*", "6"));
Output:
12346Aa
String str = "1234*Aa";
System.out.println(str.replaceAll("(\\*)+", "zx"));
Output:
1234zxAa