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.
替换'为\'使用String.replaceAll()不起作用。
'
\'
String.replaceAll()
String t="It can't be done"; String title=t.replaceAll("'", "\\\'"); syso(title);
预期输出:无法完成
您可能需要双重转义斜线。
t.replaceAll("'", "\\'")
不寻常的输出,但你需要一个额外的斜线\:
\
t.replaceAll("'", "\\\\'")