-1

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?

Javadi
  • 15
  • 2

1 Answers1

0

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

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • I got the error thanks, but "\}" didn't work. It caused illegal escape character error. I used .replace("}", "") instead. But I still wonder why it worked in desktop and not in android. – Javadi Nov 05 '22 at 09:54