3 ms·
I don't use `match` often, so I get the `match(str, regex)` order wrong. So yeah, it would be nice if gawk automatically provided the capture groups via some sp
by asicsp 4y ago
I don't use `match` often, so I get the `match(str, regex)` order wrong. So yeah, it would be nice if gawk automatically provided the capture groups via some special variable.
Not really verbose for this particular example though:
$ echo 'foo=42' | awk 'match($0, /foo=([0-9]+)/, m){print m[1]}'
42
$ echo 'foo=42' | perl -nE 'if (/foo=([0-9]+)/) { say $1 }'
42
# TIMTOWTDI
$ echo 'foo=42' | perl -nE 'say $1 if /foo=([0-9]+)/'
42