I am trying to replace the following text in some HTML:
[merchant]
I tried to use myString = myString.replace("\\[merchant\\]", "newText");
The string is not being replaced. Any ideas?
String#replace
uses string literals, not regexes, so you shouldn't escape any special characters like [
or ]
:
myString = myString.replace("[merchant]", "newText");
replace
doesnt use a regular expression. Just use