Search code examples
javaandroidreplaceall

Problem deleting "}" character in Android Java


I have a method in java in an android app that gets a String and extracts some information from it. Input has a fixed format. It contains "}" characters and they need to be deleted in process of extracting information. I tried to delete them by

.replaceAll("}", "")

method. It works on desktop but on android app, the app crashes.

I have other characters to delete and they work with no problem this way. But this special Character doesn't work. I also had problem with "{" character but then I decided to do it in another way. But "}" character can't be done other way and it needs to be specified to be deleted.

Any help?


Solution

  • ReplaceAll takes a regex, not an exact string. Use "\}" instead. Otherwise you just have an invalid regex.