public static String replaceIgnoreCase ( String pSource , String pPattern , String pReplace ) { if ( pPattern . length ( ) == 0 ) { return pSource ; // Special case: No pattern to replace } int match ; int offset = 0 ; StringBuilder result = new StringBuilder ( ) ; while ( ( match = indexOfIgnoreCase ( pSource , pPattern , offset ) ) != - 1 ) { result . append ( pSource . substring ( offset , match ) ) ; result . append ( pReplace ) ; offset = match + pPattern . length ( ) ; } result . append ( pSource . substring ( offset ) ) ; return result . toString ( ) ; }
Replaces a substring of a string with another string ignoring case . All matches are replaced .