code: public static String substitute(Pattern pattern, String text, I_CmsRegexSubstitution sub) {
  
          StringBuffer buffer = new StringBuffer();
          Matcher matcher = pattern.matcher(text);
          while (matcher.find()) {
              matcher.appendReplacement(buffer, sub.substituteMatch(text, matcher));
          }
          matcher.appendTail(buffer);
          return buffer.toString();
      }
docs: Substitutes a pattern in a string using a {@link I_CmsRegexSubstitution}.<p>
  
  @param pattern the pattern to substitute
  @param text the text in which the pattern should be substituted
  @param sub the substitution handler
  
  @return the transformed string