Search code examples
javastringreplaceall

how to replace angel bracket string


I need to replace all kinds of string that look like {\'\i} by just i

I've already read Java String ReplaceAll method giving illegal repetition error?

So I tried

String word = "something{\\\'\\\i}".replaceAll("\\\\{\\\'\\\i}", "DONE");

but it doesn't work, could anyone help me please?


Solution

  • replaceAll expects regular expressions. Instead of trying to get the RegEx right, use replace.

    String word = "something{\\'\\i}".replace("{\\'\\i}", "DONE");