我有一个包含多种特殊字符的字符串,但我只想删除"
(双引号)。
如何做到这一点?
答案 0 :(得分:5)
String s = "Hello \"there\"";
s = s.replaceAll("\"", "");
答案 1 :(得分:1)
使用Guava库:
String s = "Hello \"world\"";
s=CharMatcher.is('\"').removeFrom(s); // '\"' --> Escape the double quote(") using \
答案 2 :(得分:0)
String withQuotes = "I am a \" quote";
String withoutQuotes = withQuotes.replace("\"","");