Skip to content

regex to the file pattern glob #2008

Answered by BurntSushi
lucky3582 asked this question in Q&A
Discussion options

You must be logged in to vote

When asking questions, it is always helpful to include the actual commands you're running, along with enough info to reproduce what you're seeing. This way, we can rule out other possible problems. For example, ripgrep doesn't have any option to filter files by regexes. So the fact that you're using regexes to filter files doesn't really make any sense to me.

If you want to use a regex, then I'd combine it with xargs:

rg --files -0 | rg '/abc.[0-9]{1,2}$' --null-data | xargs -0 rg <pattern>

If your file paths don't have whitespace in them, then it could be simpler:

rg --files | rg '/abc.[0-9]{1,2}$' | xargs rg <pattern>

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@lucky3582
Comment options

@lucky3582
Comment options

@BurntSushi
Comment options

@BurntSushi
Comment options

@lucky3582
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants