我嘗試從字符串去除特殊字符,但問題是唯一的「?」仍然在輸出字符串中,而其他字符被正確刪除。爲什麼我的replaceAll不行
String[] special = {"\\*",";","_","=", "\\[", "\\]", ":", "\\?", "-", "\\.",
"\\)", "\\(", "/", "!", "#", ",", "\"", "「", "」"};
for (int i = 0; i < special.length; i++) {
source = source.replaceAll(special[i], "");
}
這是我的字符串
的[此]複製(https://stackoverflow.com/questions/13696461/replace-special-character-with-an-escape-preceded- java中的特殊字符)SO問題。 –
的可能的複製[使用轉義替換特殊字符之前在Java中的特殊字符(https://stackoverflow.com/questions/13696461/replace-special-character-with-an-escape-preceded-special-character-in- JAVA) –
我知道這是重複的,我知道如何更換工作,但我只是想知道爲什麼問號仍然出現在我的文字爲什麼別人是正確的更換 –