Class RegexReplacementTextFilter

java.lang.Object
com.opensymphony.module.sitemesh.html.rules.RegexReplacementTextFilter
All Implemented Interfaces:
TextFilter

public class RegexReplacementTextFilter extends Object implements TextFilter
TextFilter that substitutes content using a JDK 1.4 regular expression.

Example

This will substitute 'Google:Blah' for a link to a google search.
 HTMLProcessor processor = new HTMLProcessor(in, out);
 processor.addTextFilter(
         new RegexReplacementTextFilter("Google:([a-zA-Z]+)", "$1"));
 // add more TextFilters and TagRules
 processor.process();
 
Author:
Joe Walnes
  • Constructor Details

    • RegexReplacementTextFilter

      public RegexReplacementTextFilter(String regex, String replacement)
      Instantiates a new regex replacement text filter.
      Parameters:
      regex - the regex
      replacement - the replacement
    • RegexReplacementTextFilter

      public RegexReplacementTextFilter(Pattern regex, String replacement)
      Instantiates a new regex replacement text filter.
      Parameters:
      regex - the regex
      replacement - the replacement
  • Method Details

    • filter

      public String filter(String text)
      Description copied from interface: TextFilter
      Filter.
      Specified by:
      filter in interface TextFilter
      Parameters:
      text - the content
      Returns:
      the string