ripgrep can do it! :)
rg 'foo=([0-9]+)' --replace '$1'
or more succinctly: rg 'foo=([0-9]+)' -r '$1'
Example: $ echo 'quux=123 foo=123 bar=123' | rg 'foo=([0-9]+)' -r '$1'
quux=123 123 bar=123
Named groups work too: $ echo 'quux=123 foo=123 bar=123' | rg 'foo=(?P<digits>[0-9]+)' -or '$digits'
123
You can also replace the whole match by combining --replace with --only-matching: $ echo 'quux=123 foo=123 bar=123' | rg 'foo=([0-9]+)' -or '$1'
123
Of course, I understand capturing groups are useful to have in awk when you're using awk. ripgrep can only handle very simplistic cases. But they tend to be quite common.