我試圖使用函數replace()
或replaceAll()
刪除某個字符串中的特定字詞,但這些字詞會移除該字詞的所有字母,即使它是另一個字詞的一部分!刪除字符串中的特定字詞
實施例:
String content = "is not like is, but mistakes are common";
content = content.replace("is", "");
輸出:"not like , but mtakes are common"
期望的輸出:"not like , but mistakes are common"
如何從一個字符串替代全字?
如果它有Java標記,當然**這是在Java ** –
您是否需要使用replace?用字符串?你是否需要搜索不同的字符串來替換? – UNECS
你應該添加你想要替換的所有字符串的哪一部分,也許你可以使用正則表達式來完成工作 –