equal
deleted
inserted
replaced
|
1 <stránka |
|
2 xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
|
3 xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
|
4 |
|
5 <nadpis>Using relpipe-tr-sed with groups and backreferences</nadpis> |
|
6 <perex>sed-like substitution with regex groups and backreferences</perex> |
|
7 <m:pořadí-příkladu>00800</m:pořadí-příkladu> |
|
8 |
|
9 <text xmlns="http://www.w3.org/1999/xhtml"> |
|
10 |
|
11 <p> |
|
12 This tool also support regex groups and backreferences. Thus we can use parts of the matched string in our replacement string: |
|
13 </p> |
|
14 |
|
15 <m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate r 1 a string "some string xxx_123 some zzz_456 other" \ |
|
16 | relpipe-tr-sed 'r' 'a' '([a-z]{3})_([0-9]+)' '$2:$1' \ |
|
17 | relpipe-out-tabular]]></m:pre> |
|
18 |
|
19 <p>Which would convert this:</p> |
|
20 <pre><![CDATA[r: |
|
21 ╭────────────────────────────────────────╮ |
|
22 │ a (string) │ |
|
23 ├────────────────────────────────────────┤ |
|
24 │ some string xxx_123 some zzz_456 other │ |
|
25 ╰────────────────────────────────────────╯ |
|
26 Record count: 1]]></pre> |
|
27 |
|
28 <p>into this:</p> |
|
29 <pre><![CDATA[r: |
|
30 ╭────────────────────────────────────────╮ |
|
31 │ a (string) │ |
|
32 ├────────────────────────────────────────┤ |
|
33 │ some string 123:xxx some 456:zzz other │ |
|
34 ╰────────────────────────────────────────╯ |
|
35 Record count: 1]]></pre> |
|
36 |
|
37 <p> |
|
38 If there were any other relations or attributes in the stream, they would be unaffected by this transformation, |
|
39 becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes. |
|
40 </p> |
|
41 |
|
42 </text> |
|
43 |
|
44 </stránka> |