Replacing all occurrences of a substring in a string without using regex
Using a StringBuilder should always be your preferred choice when doing String manipulation. It does not always make sense, but almost always.

Additionally, indexOf takes a 'from' location, and it makes the whole thing easier.... Convert both inputs to lower-case, then do the matching using the lower-case versions, but the substrings using the unknown-case.

The complicated assign-in-where-condition logic makes the loop conditions easier, but you do need to understand what this does:

while ((find = lcbase.indexOf(lcremove, previous)) &gt;= 0) {


it searches for thelower-case remove from the previous position, saves the value to find, and checks that the result is 'positive'.... all in the condition of a while loop.

The full code is:

public static String withoutString(String base, String remove) {

    final String lcbase = base.toLowerCase();
    final String lcremove = remove.toLowerCase();
    int find = 0;
    int previous = 0;
    StringBuilder result = new StringBuilder(base.length());
    while ((find = lcbase.indexOf(lcremove, previous)) &gt;= 0) {
        result.append(base.substring(previous, find));
        previous = find + remove.length();
    }
    result.append(base.substring(previous));
    return result.toString();

}


See this running inideone