Skip to content

How does one match a pattern unless it is part of a bigger pattern? #2975

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

You must be logged in to vote

The standard technique here is to use shell pipelines. For example, rg '\w{10}' | rg -v foo. But, this requirement:

I would also like to get counts of matches per file like the --count option allows for entire directory trees currently.

Makes using shell pipelines pretty hard. At least, I can't think of a simple approach other than using --pcre2 with negative look-around. You probably want something like #875 to do this better.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
0 replies
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