str = str.replaceAll("\\\\", "");
or
str = str.replace("\\", "");
replaceAll()
treats the first argument as a regex, so you have to double escape the backslash. replace()
treats it as a literal string, so you only have to escape it once.
More Related Contents:
- Find the highest number between two literal strings using a Regular Expression
- How to parse a string that contains value only needed partially to an arraylist? [closed]
- Match multiline text using regular expression
- Regex for matching something if it is not preceded by something else
- Splitting a string at every n-th character
- removing invalid XML characters from a string in java
- How do I convert CamelCase into human-readable names in Java?
- Extracting pairs of words using String.split()
- What is the simplest way to convert a Java string from all caps (words separated by underscores) to CamelCase (no word separators)?
- Java String.split() Regex
- Java – regular expression finding comments in code
- Remove all empty lines
- Given a string, generate a regex that can parse *similar* strings
- Regular Expression to match 3 or more Consecutive Sequential Characters and Consecutive Identical Characters
- How to split a comma separated String while ignoring escaped commas?
- PatternSyntaxException: Illegal Repetition when using regex in Java
- java regex capture group
- How to remove HTML tag in Java [duplicate]
- java string split on all non-alphanumeric except apostrophes
- Find the first occurrence with Regex
- Java String ReplaceAll method giving illegal repetition error?
- Can java.util.regex.Pattern do partial matches?
- Find all words with 3 letters with regex
- Regular Expression for matching parentheses
- Replace a String between two Strings
- Does Pattern.compile cache?
- Regex to remove spaces between numbers only
- Regex Pattern Catastrophic backtracking
- Print regex matches in java
- regex replace all ignore case