Reputation: 4296
I am writing some code to remove parentheses and their contents from a String, but this line isn't working properly:
line.replaceAll("\\Q"+matchp+"\\E", rep);
This should replace all of the found group, say "(group) more words" and the regex matched "(group)", then the String would become rep + " more words". But the String is unaffected. Is quoting broken?
Upvotes: 0
Views: 148
Reputation: 70929
replaceAll
is not in-place do it like so:
line = line.replaceAll("\\Q"+matchp+"\\E", rep);
Upvotes: 11