Repository: ant Updated Branches: refs/heads/master 016fa9943 -> e9d4c9ae8
Bug 50785: example of inserting a line break Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e9d4c9ae Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e9d4c9ae Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e9d4c9ae Branch: refs/heads/master Commit: e9d4c9ae828688f8a1ea53116e165836e3245ea2 Parents: 016fa99 Author: Jan Matèrne <[email protected]> Authored: Mon Jun 8 08:42:57 2015 +0200 Committer: Jan Matèrne <[email protected]> Committed: Mon Jun 8 08:42:57 2015 +0200 ---------------------------------------------------------------------- manual/Tasks/replaceregexp.html | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/e9d4c9ae/manual/Tasks/replaceregexp.html ---------------------------------------------------------------------- diff --git a/manual/Tasks/replaceregexp.html b/manual/Tasks/replaceregexp.html index 9d1276d..eed4c84 100644 --- a/manual/Tasks/replaceregexp.html +++ b/manual/Tasks/replaceregexp.html @@ -126,7 +126,10 @@ value, in the file <code>${src}/build.properties</code></p> <substitution id="id" expression="beta\1alpha"/><br> <substitution refid="id"/> </blockquote> + + <h3>Examples</h3> + <blockquote> <pre> <replaceregexp byline="true"> @@ -141,6 +144,7 @@ value, in the file <code>${src}/build.properties</code></p> with "NewProperty" in a properties file, preserving the existing value, in all files ending in <code>.properties</code> in the current directory</p> +<br> <blockquote> <pre><replaceregexp match="\s+" replace=" " flags="g" byline="true"> <fileset dir="${html.dir}" includes="**/*.html"/> @@ -148,7 +152,6 @@ value, in all files ending in <code>.properties</code> in the current directory< </pre></blockquote> <p>replaces all whitespaces (blanks, tabs, etc) by one blank remaining the line separator. So with input - <blockquote> <pre> <html> <body> @@ -156,13 +159,47 @@ line separator. So with input <<TAB>> </body></html> </pre></blockquote> would converted to +<blockquote> <pre> <html> <body> <h1> T E S T </h1> </body></html> </pre> +</blockquote> +</p> + +<br><!-- small distance from code of the previous example --> +<blockquote> +<pre><replaceregexp match="\\n" replace="${line.separator}" flags="g" byline="true"> + <fileset dir="${dir}"/> +</replaceregexp> +</pre></blockquote> +<p>replaces all <tt>\n</tt> markers (beware the quoting of the backslash) by a line break. +So with input +<blockquote> +<pre> +one\ntwo\nthree +</pre></blockquote> +would converted to +<blockquote> +<pre> +one +two +three +</pre> +</blockquote> +Beware that inserting line breaks could break file syntax. For example in xml: +<blockquote> +<pre> +<root> + <text>line breaks \n should work in text</text> + <attribute value="but breaks \n attributes" /> +</root> +</pre> +</blockquote> </p> + </body> </html>
