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 Filter

The replace filter replaces occurances of a given regex with the supplied replacment. Optionally only the first occurance of the rege need be replaced.

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

^topParameters

AttributeDescriptionRequired
regexthe regex to be searched forYes
replacmentthe text to replace the regex withYes
firstOnlyindicates if all the regex matches should be replaced or only the firstNo, defaults to false

^topExamples

Replaces for all occurances of 'abc' with 'cba'
 <replace regex="abc" replacement="cba"/>
Replaces all decimal numbers and rounds them off to a whole
 <replace regex="([0-9]+)\.[0-9]+" replacement="$1.00"/>
Replaces the first occurance of cat or cats and replaces it with dog or dogs
 <replace regex="cat(s)*" replacement="dog$1 firstOnly="true"/>
SourceForge.net Logo