question: public static String replace ( String inString , String oldPattern , String newPattern ) { if ( ! hasLength ( inString ) || ! hasLength ( oldPattern ) || newPattern == null ) { return inString ; } StringBuilder sb = new StringBuilder ( ) ; int pos = 0 ; int index = inString . indexOf ( oldPattern ) ; int patLen = oldPattern . length ( ) ; while ( index >= 0 ) { sb . append ( inString . substring ( pos , index ) ) ; sb . append ( newPattern ) ; pos = index + patLen ; index = inString . indexOf ( oldPattern , pos ) ; } sb . append ( inString . substring ( pos ) ) ; return sb . toString ( ) ; }
target:  Replace all occurrences of a substring within a string with another string.