[Java] Replace characters by way String.replaceAll – Replace a plus character using Java’s String.replaceAll method
In some signs TH [ ^ $ . | ? * + ( ) called the special symbols. Want to replace them, Ex-character + chain do:
String str="Hello+Hello"; str=str.replaceAll("+","-"); System.out.println(str);
or
String str="Hello+Hello"; str=str.replace(Pattern.quote(str),"_"); System.out.println(str);
Recent Comments