question: public static StringBuffer replaceRegex ( StringBuffer original , String regex , String replace , boolean CASE_INSENSITIVE ) { int flags = 0 ; if ( CASE_INSENSITIVE ) flags = Pattern . CASE_INSENSITIVE ; Pattern p = Pattern . compile ( regex , flags ) ; Matcher m = p . matcher ( original ) ; StringBuffer newSB = new StringBuffer ( ) ; boolean result = m . find ( ) ; while ( result ) { m . appendReplacement ( newSB , replace ) ; result = m . find ( ) ; } m . appendTail ( newSB ) ; return newSB ; }
target:  Run RegEx Expression against original String 