我有一个字符串,当我尝试运行replaceAll
方法,我得到这个奇怪的错误:Java String 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 {
我怎样才能更换发生的"{"
?
也许更改评论:) –
@KublaiKhan::) – codaddict
@codaddict,谢谢 – Johnydep