question: private static String computeRegexString ( String originalString , String oldName , String newName ) { StringBuilder builder = new StringBuilder ( originalString . length ( ) ) ; String oldNameOrNewNameRegEx = String . format ( "(%s)|(%s)" , Pattern . quote ( oldName ) , Pattern . quote ( newName ) ) ; int i = originalString . indexOf ( oldName ) ; if ( i >= 0 ) { int prevI = 0 ; while ( i >= 0 ) { builder . append ( Pattern . quote ( originalString . substring ( prevI , i ) ) ) ; builder . append ( oldNameOrNewNameRegEx ) ; prevI = i ; i = originalString . indexOf ( oldName , i + oldName . length ( ) ) ; } builder . append ( Pattern . quote ( originalString . substring ( prevI + oldName . length ( ) , originalString . length ( ) ) ) ) ; } return builder . toString ( ) ; }
target:  Computes a regular expression string where each instance of the old name can be fulfilled by either the old name or new name.