how to specify capturing group of regular expression ?
beppe9000 opened this issue · comments
beppe9000 commented
let's say i want to print an url from a stream. I would use a regex like this cat requrest.txt | ag "location: (https\:\/\/www\.example\.com\/.*\n)"
but I don't know how to make it print only the capture group (which is the url, without the location part.)
Bruno Duyé commented
Exactly what I'm looking for.
Any solution ?
Of course I could do:
ag "url: (.*)" -o --nofilename --nocolor | grep -oP "http.*"
But this is not really satisfying
Bruno Duyé commented
For future reference, I'm now using RipGrep that allows group capturing and more