com.opensymphony.module.sitemesh.html.rules
Class RegexReplacementTextFilter
java.lang.Object
com.opensymphony.module.sitemesh.html.rules.RegexReplacementTextFilter
- All Implemented Interfaces:
- TextFilter
public class RegexReplacementTextFilter
- extends java.lang.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
Field Summary |
private java.util.regex.Pattern |
regex
|
private java.lang.String |
replacement
|
Method Summary |
java.lang.String |
filter(java.lang.String text)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
regex
private final java.util.regex.Pattern regex
replacement
private final java.lang.String replacement
RegexReplacementTextFilter
public RegexReplacementTextFilter(java.lang.String regex,
java.lang.String replacement)
RegexReplacementTextFilter
public RegexReplacementTextFilter(java.util.regex.Pattern regex,
java.lang.String replacement)
filter
public java.lang.String filter(java.lang.String text)
- Specified by:
filter
in interface TextFilter