Converts a text file using a series of regular expressions replacements.
This class implements a completely generic text processing engine.
You provide a set of regular-expression based rules,
then invoke convert to run the engine.
The simplest example is:
static final REPiece[] PATTERNS = { ... };
String outputText = (new REConverter(PATTERNS)).convert(inputText);
The devil is in the details, of course. That is,
you need to define a set of regular expression rules in the
PATTERNS variable.
Here is the beginning of a set of rules to strip HTML markup from web text:
static final REPiece[] PATTERNS = {
new REPiece("italic",
"<I>(.*?)</I>", "*$1*", Pattern.CASE_INSENSITIVE),
new REPiece("rules",
"<HR>", NL+"====================="+NL, Pattern.CASE_INSENSITIVE),
new REPiece("non-breaking spaces",
" ", " "),
new REPiece("all other tags",
"<[^>]*>", "", Pattern.DOTALL),
};