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.
More Related Contents:
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- How can non-ASCII characters be removed from a string?
- Replace the last part of a string
- Why String.replaceAll() in java requires 4 slashes “\\\\” in regex to actually replace “\”?
- Java String.replace/replaceAll not working
- String.replaceAll is considerably slower than doing the job yourself
- Search for keywords and replace them with their abbreviations [closed]
- Java: splitting a comma-separated string but ignoring commas in quotes
- String replace method is not replacing characters
- Java – escape string to prevent SQL injection
- How to unescape a Java string literal in Java?
- Replace a character at a specific index in a string?
- What are all the escape characters?
- Split string with dot as delimiter
- Splitting on comma outside quotes
- Java string split with “.” (dot) [duplicate]
- Java String replace not working [duplicate]
- Java Replacing multiple different substring in a string at once (or in the most efficient way)
- How to split a string between letters and digits (or between digits and letters)?
- Escaping special characters in Java Regular Expressions
- How to split String with some separator but without removing that separator in Java? [duplicate]
- Get the index of a pattern in a string using regex
- Java: Split string when an uppercase letter is found
- Split a string, at every nth position
- How to Split a mathematical expression on operators as delimiters, while keeping them in the result?
- How to replace ” \ ” with ” \\ ” in java
- Validate a file name on Windows
- Use Java and RegEx to convert casing in a string
- How to replace first occurrence of string in Java
- Regular Expressions on Punctuation