3 ms·
Pleasantly surprised to see an example from my ebook :) Add `-o` option to get only the digits: $ echo '[52] apples [and] [31] mangoes' | rg -o '\[(\d+)]'
by asicsp 4y ago
Pleasantly surprised to see an example from my ebook :)
Add `-o` option to get only the digits:
$ echo '[52] apples [and] [31] mangoes' | rg -o '\[(\d+)]' -r '$1'
52
31
- defrost 4y agoCongratulations (?) for making the top five google results for "ripgrep capture groups" [1]. I cite sources way more often than not, this time I got lazy after dithering over whether to go with the definitive ripgrep source page [2] or a decent looking third party(?) tutorial .. pressed for time I did neither. [1] https://learnbyexample.github.io/learn_gnugrep_ripgrep/ripgrep.html https://learnbyexample.github.io/learn_gnugrep_ripgrep/ripgr... [2] https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep