public static String removeAll(String source,String strToRemove){
  int toRemoveIndex=source.indexOf(strToRemove);
  if (toRemoveIndex != -1) {
    StringBuilder result=new StringBuilder(source.length());
    int sourceIndex=0;
    while (toRemoveIndex != -1) {
      result.append(source.substring(sourceIndex,toRemoveIndex));
      sourceIndex=toRemoveIndex + strToRemove.length();
      toRemoveIndex=source.indexOf(strToRemove,sourceIndex);
      if (toRemoveIndex == -1) {
        result.append(source.substring(sourceIndex,source.length()));
      }
    }
    return result.toString();
  }
 else {
    return source;
  }
}

public static String removeAll ( String source , String strToRemove ) { int toRemoveIndex = source . indexOf ( strToRemove ) ; if ( toRemoveIndex != - 1 ) { StringBuilder result = new StringBuilder ( source . length ( ) ) ; int sourceIndex = 0 ; while ( toRemoveIndex != - 1 ) { result . append ( source . substring ( sourceIndex , toRemoveIndex ) ) ; sourceIndex = toRemoveIndex + strToRemove . length ( ) ; toRemoveIndex = source . indexOf ( strToRemove , sourceIndex ) ; if ( toRemoveIndex == - 1 ) { result . append ( source . substring ( sourceIndex , source . length ( ) ) ) ; } } return result . toString ( ) ; } else { return source ; } }
a fast utility method that does ' nt use regex and removes all of the specified strtoremove from source .
