给定两个字符串,base和remove,返回一个版本的base字符串,其中删除了所有remove字符串的实例(不区分大小写)。您可以假设remove字符串的长度为1或更多。仅删除不重叠的实例,因此使用“xxx”删除“xx”会留下“x”。
withoutString("Hello there", "llo") → "He there"
withoutString("Hello there", "e") → "Hllo thr"
withoutString("Hello there", "x") → "Hello there"
为什么我不能使用这段代码:
public String withoutString(String base, String remove)
{
base.replace(remove, "");
return base;
}