Skip to content

Commit

Permalink
Add documentation for the replaceregexp task
Browse files Browse the repository at this point in the history
Submitted by:	Matthew Inger <[email protected]>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269900 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bodewig committed Nov 12, 2001
1 parent 28897dd commit 0c1f46d
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bootstrap.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if not "%OS%" == "Windows_NT" if exist bootstrap\nul deltree/y bootstrap
if "%OS%" == "Windows_NT" if exist build\classes\nul rmdir/s/q build\classes
if not "%OS%" == "Windows_NT" if exist build\classes\nul deltree/y build\classes

SET LOCALCLASSPATH=lib\crimson.jar;lib\jaxp.jar;
SET LOCALCLASSPATH=lib\crimson.jar
for %%i in (lib\optional\*.jar) do call src\script\lcp.bat %%i
if exist "%JAVA_HOME%\lib\tools.jar" call src\script\lcp.bat %JAVA_HOME%\lib\tools.jar
if exist "%JAVA_HOME%\lib\classes.zip" call src\script\lcp.bat %JAVA_HOME%\lib\classes.zip
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if [ -d "build/classes" ] ; then
rm -r build/classes
fi

CLASSPATH=lib/crimson.jar:lib/jaxp.jar:${CLASSPATH}
CLASSPATH=lib/crimson.jar:${CLASSPATH}

DIRLIBS=lib/optional/*.jar
for i in ${DIRLIBS}
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo Bootstrap FAILED
goto cleanup

:runAnt
set LOCALCLASSPATH=lib\crimson.jar;lib\jaxp.jar;bootstrap\lib\ant.jar
set LOCALCLASSPATH=lib\crimson.jar;bootstrap\lib\ant.jar
for %%i in (lib\optional\*.jar) do call bootstrap\bin\lcp.bat %%i
set CLASSPATH=lib\optional\xalanj1compat.jar;%LOCALCLASSPATH%;%CLASSPATH%
set LOCALCLASSPATH=
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if test ! -f bootstrap/lib/ant.jar -o ! -x bootstrap/bin/ant -o ! -x bootstrap/
exit
fi

LOCALCLASSPATH=lib/crimson.jar:lib/jaxp.jar
LOCALCLASSPATH=lib/crimson.jar
# add in the dependency .jar files
DIRLIBS=lib/optional/*.jar
for i in ${DIRLIBS}
Expand Down
116 changes: 116 additions & 0 deletions docs/manual/OptionalTasks/replaceregexp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Ant User Manual</title>
</head>

<body>

<h2><a name="replace">ReplaceRegExp</a></h2>
<h3>Description</h3>
<p>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.</p>

<p>Similar to <a href="../CoreTypes/mapper.html#regexp-mapper">regexp
type mappers</a> this task needs a supporting regular expression
library and an implementation of
<code>org.apache.tools.ant.util.regexp.Regexp</code>. Ant comes with
implementations for
<a href="http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary.html" target="_top">the java.util.regex package of JDK 1.4</a>,
<a href="http://jakarta.apache.org/regexp/" target="_top">jakarta-regexp</a>
and <a href="http://jakarta.apache.org/oro/" target="_top">jakarta-ORO</a>,
but you will still need the library itself.</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">file</td>
<td valign="top">file for which the regular expression should be replaced.</td>
<td align="center">Yes if no nested &lt;fileset&gt; is used</td>
</tr>
<tr>
<td valign="top">match</td>
<td valign="top">The regular expression pattern to match in the file(s)</td>
<td align="center">Yes, if no nested &lt;regularexpression&gt; is used</td>
</tr>
<tr>
<td valign="top">replace</td>
<td valign="top">The substition pattern to place in the file(s) in place
of the regular expression.</td>
<td align="center">Yes, if no nested &lt;substitution&gt; is used</td>
</tr>
<tr>
<td valign="top">flags</td>
<td valign="top">The flags to use when matching the regular expression. For more
information, consult the Perl5 syntax<br />
g --> Global replacement. Replace all occurances found<br />
i --> Case Insensitive. Do not consider case in the match<br />
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.<br />
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.<br />
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">byline</td>
<td valign="top">Process the file(s) one line at a time, executing the replacement
on one line at a time (<i>true/false</i>). This is useful if you
want to only replace the first occurance of a regular expression on
each line, which is not easy to do when processing the file as a whole.
Defaults to <i>false</i>.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<pre> &lt;replaceregexp file=&quot;${src}/build.properties&quot;
match=&quot;OldProperty=(.*)&quot;
replace=&quot;NewProperty=\1&quot;
byline=&quot;true&quot; /&gt;
</pre>
<p>replaces occurrences of the property name &quot;OldProperty&quot;
with &quot;NewProperty&quot; in a properties file, preserving the existing
value, in the file <code>${src}/build.properties</code></p>
<h3>Parameters specified as nested elements</h3>
<p>This task supports a nested <a href="../CoreTypes/fileset.html">FileSet</a>
element.</p>
<p>This task supports a nested <i>RegularExpression</i> element to specify
the regular expression. You can use this element to refer to a previously
defined regular expression datatype instance.</p>
<blockquote>
&lt;regularexpression id="id" pattern="expression" /&gt;<br />
&lt;regularexpression refid="id" /&gt;
</blockquote>
<p>This task supports a nested <i>Substitution</i> element to specify
the substitution pattern. You can use this element to refer to a previously
defined substition pattern datatype instance.</p>
<blockquote>
&lt;substitution id="id" pattern="expression" /&gt;<br />
&lt;substitution refid="id" /&gt;
</blockquote>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;replaceregexp byline=&quot;true&quot;&gt;
&lt;regularexpression expression=&quot;OldProperty=(.*)&quot; /&gt;
&lt;substitution expression=&quot;NewProperty=\1&quot; /&gt;
&lt;fileset dir=&quot;.&quot;&gt;
&lt;includes=&quot;*.properties&quot; /&gt;
&lt;/fileset&gt;
&lt;/replaceregexp&gt;
</pre></blockquote>
<p>replaces occurrences of the property name &quot;OldProperty&quot;
with &quot;NewProperty&quot; in a properties file, preserving the existing
value, in all files ending in <code>.properties</code> in the current directory</p>

<hr>
<p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
Reserved.</p>

</body>
</html>

1 change: 1 addition & 0 deletions docs/manual/optionaltasklist.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h3>Optional Tasks</h3>
<a href="OptionalTasks/propertyfile.html">PropertyFile</a><br>
<a href="OptionalTasks/pvcstask.html">Pvcs</a><br>
<a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br>
<a href="OptionalTasks/replaceregexp.html">ReplaceRegExp</a><br>
<a href="OptionalTasks/rpm.html">Rpm</a><br>
<a href="OptionalTasks/script.html">Script</a><br>
<a href="OptionalTasks/sound.html">Sound</a><br>
Expand Down

0 comments on commit 0c1f46d

Please sign in to comment.