I have a string and when I try to run the replaceAll
method, I am getting this strange error:
String str = "something { } , op";
str = str.replaceAll("o", "\n"); // it works fine
str = str.replaceAll("{", "\n"); // does not work
and i get a strange error:
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal repetition {
How can I replace the occurrences of "{"
?
replace()
just replaced the first instance. That's what I get for not looking at the docs! – Eyeful