我试图使用函数
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"
如何从字符串中仅替换整个单词?