question: public String replace ( String input ) { int lastAppendPos = 0 ; Matcher matcher = pattern . matcher ( input ) ; StringBuilder sb = new StringBuilder ( ) ; while ( matcher . find ( ) ) { sb . append ( input , lastAppendPos , matcher . start ( ) ) ; sb . append ( getReplacement ( matcher ) ) ; lastAppendPos = matcher . end ( ) ; } sb . append ( input , lastAppendPos , input . length ( ) ) ; return sb . toString ( ) ; }
target:  Replaces anything in the input String, based on the Map specified for this Replacer.