我需要转义字符串中的所有引号('),这样它就变成了\‘
我试过使用replaceAll,但它什么也做不了。由于某些原因,我不能让正则表达式工作。
我正在试着
String s = "You'll be totally awesome, I'm really terrible";
String shouldBecome = "You\'ll be totally awesome, I\'m really terrible";
s = s.replaceAll("'","\\'"); // Doesn't do anything
s = s.replaceAll("\'","\\'"); // Doesn't do anything
s = s.replaceAll("\\'","\\'"); // Doesn't do anything
我真的被困在这里了,希望有人能帮我。
谢谢,
Iwan
https://stackoverflow.com/questions/20556101
复制相似问题