|
ReplaceRegExpDescriptionReplaceRegExp is a directory based task for replacing the occurrence of a given regular expression with a substitution pattern in a selected file or set of files. Similar to regexp
type mappers this task needs a supporting regular expression
library and an implementation of
There are cross-platform issues for matches related to line terminator.
For example if you use $ to anchor your regular expression on the end of a line
the results might be very different depending on both your platform and the regular
expression library you use. It is 'highly recommended' that you test your pattern on
both Unix and Windows platforms before you rely on it.
Parameters
Examples<replaceregexp file="${src}/build.properties" match="OldProperty=(.*)" replace="NewProperty=\1" byline="true"/> replaces occurrences of the property name "OldProperty"
with "NewProperty" in a properties file, preserving the existing
value, in the file Parameters specified as nested elementsThis task supports a nested FileSet element. This task supports a nested Regexp element to specify the regular expression. You can use this element to refer to a previously defined regular expression datatype instance. <regexp id="id" pattern="expression"/> This task supports a nested Substitution element to specify the substitution pattern. You can use this element to refer to a previously defined substitution pattern datatype instance. <substitution id="id" pattern="expression"/> Examples<replaceregexp byline="true"> <regexp pattern="OldProperty=(.*)"/> <substitution expression="NewProperty=\1"/> <fileset dir="."> <includes="*.properties"/> </fileset> </replaceregexp> replaces occurrences of the property name "OldProperty"
with "NewProperty" in a properties file, preserving the existing
value, in all files ending in Copyright © 2001-2002 Apache Software Foundation. All rights Reserved. |