Sed capture group not working

Viewed 4655

This seems like one of the sipmlest possible examples of a sed capture group, and it doesn't work. I've tested the regex in online regex testers, and does what I want. At the linux command line it does not.

$ echo "a 10 b 12" | sed -E -n 's/a ([0-9]+)/\1/p'
$

and

$ echo "a 10 b 12" | sed -E -n 's/a ([0-9]+)/\1/p'
10 b 12

https://regex101.com/r/WS3lG9/1

I would expect the "10" to be captured.

2 Answers
Related