code: public static Filter replaceInString(
              final Pattern regexp,
              final String replacement,
              final int overlap) {
          return new FilterAdapter() {
              private String string;
  
              @Override
              protected String doBeforeAppend(String string, StringBuilder buffer) {
                  this.string = string;
                  return string;
              }
  
              @Override
              protected boolean doAfterAppend(StringBuilder buffer) {
                  int pos = string == null
                          ? 0
                          : Math.max(0, buffer.length() - string.length() - overlap);
  
                  final Matcher matcher = regexp.matcher(buffer.substring(pos));
                  final String str = matcher.replaceAll(replacement);
                  buffer.replace(pos, buffer.length(), str);
  
                  return false;
              }
          };
      }
docs: Creates a filter which replaces every substring in the input string that matches the given
  regular expression
  and replaces it with given replacement.
  <p/>
  The method just calls {@link String#replaceAll(String, String)} for the input string.
  
  @param regexp      the regular expression
  @param replacement the string to be substituted for each match
  @param overlap     the number of characters prepended to the matching string from the
  previous data chunk before match
  @return the filter