Home| Design| License| Regex| Download| Credits| Contact
Text-Zap Info
› Overview› Text-Zap Ant Task› Expand Text-Zap› API Docs
Components
› Filters› Savers› Groupers› Sequencers
Filters
› Append Filter› Append File Filter› Extract Lines Filter› Find Filter› Insert References› Merge Filter› Replace Filter› Replace List Filter› Replace Filter Plus› Reverse Filter› Split By Regex Filter› XSLT Filter

Replace List Filter

The replace filter replaces all occurrences of many given regexs with the supplied replacements. These regexs are pulled from a file whose name is supplied as a parameter.

The replacements may refer back to capturing groups to include part(s) of the regex in the in the replacement. (See the quick regex tutorial for more details about capturing groups and other regex info.)

Optionally a prefix and/or suffix may be supplied to be added on to each regex as they are processed.

The structure for the matchfile is discussed below.

^topParameters

AttributeDescriptionRequired
matchfilethe file containing the regexs to be replacedYes
prefixa regex to append to the beginning of all regexs in the matchfileNo
suffixa regex to append to the end of all regexs in the matchfileNo

^topExamples

Replaces all regex's in file "match.txt"
 <replaceList matchfile="match.txt"/>
Replaces all regexs found in file "match.txt" adding a '#' to the beginning of each regex
 <replaceList matchfile="match.txt" prefix="#"/>

^topMatchfile Structure

The matchfile must be structured like a standard Java properties file. This means that each regex should be on its own line with an = between the regex and the replacment. No lines should be skiped. Any line that begins with a # is consdiered to be be a comment an will be ignored. The display should list the line number of any line that does not conform to these requirements.

Here is an example of what a matchfile could look like:
 
abc=cba
#this is a comment and will be ignored
cat=dog
cat(s)*=dog$1
good day=good night

SourceForge.net Logo