Reputation: 2528
I have a string that looks like this:
<a href=\"test\" />
I want to to replace the /"
to "
, so that it looks like this <a href="test" />
.
Therefore I am using this piece of code:
content = content.replaceAll("\\\"", "\"");
For some reason it doesn't find \"
. So it isn't being replaced.
Upvotes: 1
Views: 1088
Reputation: 59363
replaceAll
takes a regex. Therefore, you must escape the escape like this:
s = s.replaceAll("\\\\\"", "\"");
Upvotes: 2
Reputation: 4472
Try this code: string.replaceAll(Pattern.quote("\\\""), "\"");
Upvotes: 3