如何从包含多种特殊字符的字符串中删除特定的特殊字符

时间:2010-11-25 07:44:06

标签: java

我有一个包含多种特殊字符的字符串,但我只想删除"(双引号)。

如何做到这一点?

3 个答案:

答案 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("\"","");