re
re copied to clipboard
Option request: Wrap capture groups with string or character
Specify wrap char/string: -e "."
To auto escape occurences of wrap char/string: -a
In use:
$ ifconfig | re -e "\"" -g "(?P<IF>eth\d+).+?inet addr:(?P<IP>[\d.]+)"
IF="eth0", IP="10.0.0.100", IF="eth1", IP="10.0.0.101"
Do you have an example of when this would be useful? You could potentially do something like this:
$ ifconfig | re -g "(?P<IF>eth\d+).+?inet addr:(?P<IP>[\d.]+)" | re 's/=([^,]+)/="${1}"/'
IF="eth0", IP="10.0.0.200"
$ re -dr ", " "([^ .][^.]*)" <<< "hello world, foo bar. baz qux."
hello world, foo bar, baz qux
vs.
$ re -e -dr ", " "([^ .][^.]*)" <<< "hello world, foo bar. baz qux."
"hello world, foo bar", "baz qux"
(if default char/string is " when using -e option with no param)