Attached is the source for a task that performs a regular _expression_ substitution inline on a file or a set of files.
The substitution pattern can contain references to subexpressions within the find pattern, which makes it possible to use fragments of the original text in the new text.
The syntax and implementation borrows from the replace task, for example:
<rereplace file="${src}/index.html" find="f([ae])ll" replaceWith="b$$1ll" />
will replace all occurrences of "fall" or "fell" in index.html with "ball" and "bell", respectively.
This implementation relies upon the jakarta-oro regular _expression_ package (see http://jakarta.apache.org/oro), although it is relatively simply to modify the code to support alternative regular _expression_ packages.
Documentation and some examples can be found in the attached archive.
I've seen a few requests for this functionality on the list, and I've found this task to be useful, so I thought others might also. In theory, this could replace the replace task altogether, but I've packaged it as optional since it depends upon the oro library.
(The archive also includes a support class that implements an arbitrary nested element containing text, which may be independently useful.)
Enjoy,
Rod Waldhoff <[EMAIL PROTECTED]>
rereplace-task.jar
Description: Binary data
