code: public static String regexpReplace(String str, String regex, String replacement) {
  		if (regex.isEmpty()) {
  			return str;
  		}
  		try {
  			// we should use StringBuffer here because Matcher only accept it
  			StringBuffer sb = new StringBuffer();
  			Matcher m = REGEXP_PATTERN_CACHE.get(regex).matcher(str);
  			while (m.find()) {
  				m.appendReplacement(sb, replacement);
  			}
  			m.appendTail(sb);
  			return sb.toString();
  		} catch (Exception e) {
  			LOG.error(
  				String.format("Exception in regexpReplace('%s', '%s', '%s')", str, regex, replacement),
  				e);
  			// return null if exception in regex replace
  			return null;
  		}
  	}
docs: Returns a string resulting from replacing all substrings that match the regular
  expression with replacement.