relpipe-data/examples-rename-groups-backreferences.xml
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
child 329 5bc2bb8b7946
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-rename-groups-backreferences.xml	Tue Feb 05 19:18:28 2019 +0100
@@ -0,0 +1,44 @@
+<stránka
+	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
+	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
+	
+	<nadpis>Using relpipe-tr-sed with groups and backreferences</nadpis>
+	<perex>sed-like substitution with regex groups and backreferences</perex>
+	<m:pořadí-příkladu>00800</m:pořadí-příkladu>
+
+	<text xmlns="http://www.w3.org/1999/xhtml">
+	
+		<p>
+			This tool also support regex groups and backreferences. Thus we can use parts of the matched string in our replacement string:
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate r 1 a string "some string xxx_123 some zzz_456 other" \
+	| relpipe-tr-sed 'r' 'a' '([a-z]{3})_([0-9]+)' '$2:$1' \
+	| relpipe-out-tabular]]></m:pre>
+		
+		<p>Which would convert this:</p>
+		<pre><![CDATA[r:
+ ╭────────────────────────────────────────╮
+ │ a                             (string) │
+ ├────────────────────────────────────────┤
+ │ some string xxx_123 some zzz_456 other │
+ ╰────────────────────────────────────────╯
+Record count: 1]]></pre>
+		
+		<p>into this:</p>
+		<pre><![CDATA[r:
+ ╭────────────────────────────────────────╮
+ │ a                             (string) │
+ ├────────────────────────────────────────┤
+ │ some string 123:xxx some 456:zzz other │
+ ╰────────────────────────────────────────╯
+Record count: 1]]></pre>
+
+		<p>
+			If there were any other relations or attributes in the stream, they would be unaffected by this transformation,
+			becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes.
+		</p>
+		
+	</text>
+
+</stránka>