I have two strings and want to replace one string from the other. The problem is that strings have meta characters.
E.g.
String string1 = "I am foo";
String string2 = "I am bar and I am foo. I am both.";
string2 = string2.replaceAll(string1, ""); does the replacement.
Suppose I have the following strings.
String string1 = "I + am - foo [].";
String string2 = "I + am bar and I + am - foo []. I am both.";
Then the answer should be : "I + am bar and I am both."
How can we perform the replacement?
I know
java.util.regex.Pattern.quote("xyz")
escapes the characters, but in this case, there are many meta characters.
Thanks.