我有一个字符串,当我尝试运行该replaceAll
方法时,我收到了这个奇怪的错误:
String str = "something { } , op";
str = str.replaceAll("o", "\n"); // it works fine
str = str.replaceAll("{", "\n"); // does not work
我得到一个奇怪的错误:
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal repetition {
如何替换 的出现"{"
?