Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这让我很生气,所以如果可以的话,请帮忙......
我有一个 Java 字符串,我想用单引号替换所有反斜杠双引号序列,即使我正在转义我认为必要的内容,replace 命令对字符串没有任何作用。
entry.replace("\\\"", "'");
感谢任何建议。
谢谢。
在 Java 中,字符串是不可变的。您对 String 执行的任何操作都会产生新对象。操作后需要重新赋值。以下可能对您有所帮助。
entry = entry.replace("\\\"", "'");
我总是犯的常见错误:)
你应该这样做:entry = entry.replace("\\\"", "'");