static private StringBuilder replace ( StringBuilder input , java . util . regex . Pattern pattern , String replacement ) { java . util . regex . Matcher m = pattern . matcher ( input ) ; while ( m . find ( ) ) { if ( isEscapedChar ( input . toString ( ) , m . start ( ) ) ) { continue ; } // since we're replacing the original string being matched, // we have to reset the matcher so that it searches the new // string input . replace ( m . start ( ) , m . end ( ) , replacement ) ; m . reset ( input ) ; } return input ; }
Replaces strings matching a pattern with another string . If the string to be replaced is escaped with a slash it is skipped .