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.
我有一个看起来像这样的字符串:
<a href=\"test\" />
我想替换/"to ",使它看起来像这样<a href="test" />。
/"
"
<a href="test" />
因此我正在使用这段代码:
content = content.replaceAll("\\\"", "\"");
由于某种原因,它没有找到\". 所以不会被替换。
\"
试试这个代码:string.replaceAll(Pattern.quote("\\\""), "\"");
string.replaceAll(Pattern.quote("\\\""), "\"");
replaceAll需要一个正则表达式。因此,您必须像这样逃脱逃脱:
replaceAll
s = s.replaceAll("\\\\\"", "\"");