簡體   English   中英

如何從具有多種特殊字符類型的字符串中刪除特定特殊字符

[英]How to remove a specific special character from a string with many types of special characters

我有一個帶有許多特殊字符類型的字符串,但是我只想刪除" (雙引號)。

如何才能做到這一點?

String s = "Hello \"there\"";
s = s.replaceAll("\"", "");

使用番石榴庫:

String s = "Hello \"world\"";
s=CharMatcher.is('\"').removeFrom(s); // '\"' --> Escape the double quote(") using \
String withQuotes    = "I am a \" quote";
String withoutQuotes = withQuotes.replace("\"","");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM