This tool also support regex groups and backreferences. Thus we can use parts of the matched string in our replacement string:
relpipe-in-cli \
--relation 'r' \
--attribute 'a' string \
--record 'some string xxx_123 some zzz_456 other' \
| relpipe-tr-sed \
--relation 'r' \
--attribute 'a' \
--value '([a-z]{3})_([0-9]+)' \
--replacement '$2:$1' \
| relpipe-out-tabular
Which would convert this:
r: ╭────────────────────────────────────────╮ │ a (string) │ ├────────────────────────────────────────┤ │ some string xxx_123 some zzz_456 other │ ╰────────────────────────────────────────╯ Record count: 1
into this:
r: ╭────────────────────────────────────────╮ │ a (string) │ ├────────────────────────────────────────┤ │ some string 123:xxx some 456:zzz other │ ╰────────────────────────────────────────╯ Record count: 1
If there were any other relations or attributes in the stream, they would be unaffected by this transformation,
becase we specified 'r' 'a'
instead of some wider regular expression that would match more relations or attributes.
Relational pipes, open standard and free software © 2018-2022 GlobalCode