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?
On
String#replace uses string literals, not regexes, so you shouldn't escape any special characters like [ or ]:
myString = myString.replace("[merchant]", "newText");
replacedoesnt use a regular expression. Just use