From 753a6c60f47f3ac4f270005b65e9d6481de8eb68 Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Fri, 23 Oct 2015 10:00:02 -0700 Subject: Adding maven and ant source trees Change-Id: I0a39b9add833a31b9c3f98d193983ae2f3a5a445 Signed-off-by: Ashlee Young --- .../manual/Tasks/replaceregexp.html | 205 +++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 framework/src/ant/apache-ant-1.9.6/manual/Tasks/replaceregexp.html (limited to 'framework/src/ant/apache-ant-1.9.6/manual/Tasks/replaceregexp.html') diff --git a/framework/src/ant/apache-ant-1.9.6/manual/Tasks/replaceregexp.html b/framework/src/ant/apache-ant-1.9.6/manual/Tasks/replaceregexp.html new file mode 100644 index 00000000..eed4c84c --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/manual/Tasks/replaceregexp.html @@ -0,0 +1,205 @@ + + + + + + +ReplaceRegExp Task + + + +

ReplaceRegExp

+

Description

+

ReplaceRegExp 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.

+ +

The output file is only written if it differs from the existing +file. This prevents spurious rebuilds based on unchanged files which +have been regenerated by this task.

+ +

Similar to regexp +type mappers this task needs a supporting regular expression +library and an implementation of +org.apache.tools.ant.util.regexp.Regexp. +See details in the documentation of the Regexp Type.

+ +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
filefile for which the regular expression should be replaced.Yes if no nested <fileset> is used
matchThe regular expression pattern to match in the file(s)Yes, if no nested <regexp> is used
replaceThe substitution pattern to place in the file(s) in place + of the regular expression.Yes, if no nested <substitution> is used
flagsThe flags to use when matching the regular expression. For more + information, consult the Perl5 syntax
+ g : Global replacement. Replace all occurrences found
+ i : Case Insensitive. Do not consider case in the match
+ m : Multiline. Treat the string as multiple lines of input, using "^" and "$" as the start or end of any line, respectively, rather than start or end of string.
+ s : Singleline. Treat the string as a single line of input, using "." to match any character, including a newline, which normally, it would not match.
+
No
bylineProcess the file(s) one line at a time, executing the replacement + on one line at a time (true/false). This is useful if you + want to only replace the first occurrence of a regular expression on + each line, which is not easy to do when processing the file as a whole. + Defaults to false.No
encodingThe encoding of the file. since Apache Ant 1.6No - defaults to default JVM encoding
preserveLastModifiedKeep the file timestamp(s) even if the file(s) + is(are) modified. since Ant 1.8.0.No, defaults to false
+

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 ${src}/build.properties

+ +

Parameters specified as nested elements

+

This task supports a nested FileSet + element.

+

Since Ant 1.8.0 this task supports any filesystem + based resource + collections as nested elements.

+

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="alpha(.+)beta"/>
+ <regexp refid="id"/> +
+

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" expression="beta\1alpha"/>
+ <substitution refid="id"/> +
+ + +

Examples

+ +
+
+<replaceregexp byline="true">
+  <regexp pattern="OldProperty=(.*)"/>
+  <substitution expression="NewProperty=\1"/>
+  <fileset dir=".">
+    <include name="*.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 .properties in the current directory

+ +
+
+
<replaceregexp match="\s+" replace=" " flags="g" byline="true">
+    <fileset dir="${html.dir}" includes="**/*.html"/>
+</replaceregexp>
+
+

replaces all whitespaces (blanks, tabs, etc) by one blank remaining the +line separator. So with input +

+
+<html>    <body>
+<<TAB>><h1>    T E S T   </h1>  <<TAB>>    
+<<TAB>> </body></html>
+
+would converted to +
+
+<html> <body>
+ <h1> T E S T </h1> </body></html>
+
+
+

+ +
+
+
<replaceregexp match="\\n" replace="${line.separator}" flags="g" byline="true">
+    <fileset dir="${dir}"/>
+</replaceregexp>
+
+

replaces all \n markers (beware the quoting of the backslash) by a line break. +So with input +

+
+one\ntwo\nthree
+
+would converted to +
+
+one
+two
+three
+
+
+Beware that inserting line breaks could break file syntax. For example in xml: +
+
+<root>
+  <text>line breaks \n should work in text</text>
+  <attribute value="but breaks \n attributes" />
+</root>
+
+
+

+ + + + + + -- cgit 1.2.3-korg