author | František Kučera <franta-hg@frantovo.cz> |
Sat, 06 Jun 2020 13:22:57 +0200 | |
branch | v_0 |
changeset 300 | b9bd0f06b4a1 |
parent 244 | d4f401b5f90c |
child 329 | 5bc2bb8b7946 |
permissions | -rw-r--r-- |
23
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
1 |
<stránka |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
2 |
xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
3 |
xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
4 |
|
244
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
5 |
<nadpis>Using relpipe-tr-sed with groups and backreferences</nadpis> |
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
6 |
<perex>sed-like substitution with regex groups and backreferences</perex> |
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
7 |
<m:pořadí-příkladu>00800</m:pořadí-příkladu> |
4
1bb39595a51c
genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
8 |
|
2
ab9099ff88fa
vkládání zápatí, jmenné prostory, saxon
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
9 |
<text xmlns="http://www.w3.org/1999/xhtml"> |
185
6cd2e54d90ea
examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents:
184
diff
changeset
|
10 |
|
6cd2e54d90ea
examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents:
184
diff
changeset
|
11 |
<p> |
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
12 |
This tool also support regex groups and backreferences. Thus we can use parts of the matched string in our replacement string: |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
13 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
14 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
15 |
<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate r 1 a string "some string xxx_123 some zzz_456 other" \ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
16 |
| relpipe-tr-sed 'r' 'a' '([a-z]{3})_([0-9]+)' '$2:$1' \ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
17 |
| relpipe-out-tabular]]></m:pre> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
18 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
19 |
<p>Which would convert this:</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
20 |
<pre><![CDATA[r: |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
21 |
╭────────────────────────────────────────╮ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
22 |
│ a (string) │ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
23 |
├────────────────────────────────────────┤ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
24 |
│ some string xxx_123 some zzz_456 other │ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
25 |
╰────────────────────────────────────────╯ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
26 |
Record count: 1]]></pre> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
27 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
28 |
<p>into this:</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
29 |
<pre><![CDATA[r: |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
30 |
╭────────────────────────────────────────╮ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
31 |
│ a (string) │ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
32 |
├────────────────────────────────────────┤ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
33 |
│ some string 123:xxx some 456:zzz other │ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
34 |
╰────────────────────────────────────────╯ |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
35 |
Record count: 1]]></pre> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
36 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
37 |
<p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
38 |
If there were any other relations or attributes in the stream, they would be unaffected by this transformation, |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
39 |
becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes. |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
40 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
41 |
|
87
25dec6931f18
Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
42 |
</text> |
4
1bb39595a51c
genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
43 |
|
1 | 44 |
</stránka> |