<分区>
我想用 ^
替换字符串中的 "
。
String str = "hello \"there";
System.out.println(str);
String str1 = str.replaceAll("\"", "^");
System.out.println(str1);
String str2= str1.replaceAll("^", "\"");
System.out.println(str2);
输出是:
hello "there
hello ^there
"hello ^there
为什么我在字符串的开头得到额外的 "
而在字符串之间得到 ^
我期待:
hello "there