public static String getSubString(String str1, String str2) { StringBuffer sb = new StringBuffer(str1); while (true) { int index = sb.indexOf(str2); if (index == -1) { break; } sb.delete(index, index + str2.length()); } return sb.toString(); }