Remove all occurrences of \ from string

Try this:

String jsonFormattedString = jsonStr.replaceAll("\\\\", "");

Because the backslash is the escaping character in a regular expression (replaceAll() receives one as parameter), it has to be escaped, too.

Leave a Comment