From e9d4c9ae828688f8a1ea53116e165836e3245ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mat=C3=A8rne?= Date: Mon, 8 Jun 2015 08:42:57 +0200 Subject: [PATCH] Bug 50785: example of inserting a line break --- manual/Tasks/replaceregexp.html | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/manual/Tasks/replaceregexp.html b/manual/Tasks/replaceregexp.html index 9d1276d09..eed4c84c4 100644 --- a/manual/Tasks/replaceregexp.html +++ b/manual/Tasks/replaceregexp.html @@ -126,7 +126,10 @@ value, in the file ${src}/build.properties

<substitution id="id" expression="beta\1alpha"/>
<substitution refid="id"/> + +

Examples

+
 <replaceregexp byline="true">
@@ -141,6 +144,7 @@ value, in the file ${src}/build.properties

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"/>
@@ -148,7 +152,6 @@ value, in all files ending in .properties in the current directory<
 

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

 <html>    <body>
@@ -156,13 +159,47 @@ line separator. So with input
 <<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>
+
+

+