You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2015/06/08 08:44:27 UTC

ant git commit: Bug 50785: example of inserting a line break

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 <jh...@apache.org>
Authored: Mon Jun 8 08:42:57 2015 +0200
Committer: Jan Matèrne <jh...@apache.org>
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>
      &lt;substitution id="id" expression="beta\1alpha"/&gt;<br>
      &lt;substitution refid="id"/&gt;
 </blockquote>
+
+
 <h3>Examples</h3>
+
 <blockquote>
   <pre>
 &lt;replaceregexp byline=&quot;true&quot;&gt;
@@ -141,6 +144,7 @@ value, in the file <code>${src}/build.properties</code></p>
  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>
 
+<br>
 <blockquote>
 <pre>&lt;replaceregexp match="\s+" replace=" " flags="g" byline="true"&gt;
     &lt;fileset dir="${html.dir}" includes="**/*.html"/&gt;
@@ -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>
 &lt;html&gt;    &lt;body&gt;
@@ -156,13 +159,47 @@ line separator. So with input
 &lt;&lt;TAB&gt;&gt; &lt;/body&gt;&lt;/html&gt;
 </pre></blockquote>
 would converted to
+<blockquote>
 <pre>
 &lt;html&gt; &lt;body&gt;
  &lt;h1&gt; T E S T &lt;/h1&gt; &lt;/body&gt;&lt;/html&gt;
 </pre>
+</blockquote>
+</p>
+
+<br><!-- small distance from code of the previous example -->
+<blockquote>
+<pre>&lt;replaceregexp match="\\n" replace="${line.separator}" flags="g" byline="true"&gt;
+    &lt;fileset dir="${dir}"/&gt;
+&lt;/replaceregexp&gt;
+</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>
+&lt;root&gt;
+  &lt;text&gt;line breaks \n should work in text&lt;/text&gt;
+  &lt;attribute value=&quot;but breaks \n attributes&quot; /&gt;
+&lt;/root&gt;
+</pre>
+</blockquote>
 </p>
 
 
+
 </body>
 </html>