I’m trying to replace the “^” character on a String using:
String text = text.replaceAll("^", "put this text");
If text as the following value:
"x^my string"
The resulting String is:
"put this textx^my string"
This only happens in case of the ^ character
Why is this?
Just use the non-regex version
String.replace()instead ofString.replaceAll():