A {
is a regex meta-character used for range repetitions as {min,max}
. To match a literal {
you need to escape it by preceding it with a \\
:
str = str.replaceAll("\\{", "\n"); // does work
More Related Contents:
- Regex for converting xml tags key to camel case
- How to split a string if any chracter is found in java
- Java: splitting a comma-separated string but ignoring commas in quotes
- Splitting a Java String by the pipe symbol using split(“|”)
- Split string to equal length substrings in Java
- Split string with dot as delimiter
- How to extract a substring using regex
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- Why does String.split need pipe delimiter to be escaped?
- Using Java to find substring of a bigger string using Regular Expression
- Get the index of a pattern in a string using regex
- How to use regex in String.contains() method in Java
- Compare one String with multiple values in one expression
- Replace the last part of a string
- How do I convert CamelCase into human-readable names in Java?
- Remove trailing zero in Java
- Extract string between two strings in java
- 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
- How to replace ” \ ” with ” \\ ” in java
- Validate a file name on Windows
- Check if string ends with certain pattern
- Java split is eating my characters
- Java String.replace/replaceAll not working
- Remove all non-“word characters” from a String in Java, leaving accented characters?
- How to implement a SQL like ‘LIKE’ operator in java?
- Raw Strings in Java – for regex in particular. Multiline strings
- How can I remove punctuation from input text in Java?
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string