public static String replaceAll ( final String input , final String pattern , final String replacement ) { final StringBuilder result = new StringBuilder ( ) ; int startIndex = 0 ; int newIndex ; while ( ( newIndex = input . indexOf ( pattern , startIndex ) ) >= 0 ) { result . append ( input , startIndex , newIndex ) ; result . append ( replacement ) ; startIndex = newIndex + pattern . length ( ) ; } result . append ( input . substring ( startIndex ) ) ; return result . toString ( ) ; }
Replaces each substring of this string that matches the given string with the given replacement . Differ from the JDK String . replaceAll function this method does not support regular expression based replacement on purpose .