Skip to content
Discussion options

You must be logged in to vote

This isn't a bug and it is the intended semantic. ripgrep provides no way to do what you want. A work-around, assuming your pattern file is just a list of literals (i.e., not regexes) is to sort your patterns in descending order of length. This guarantees that no preceding pattern is a prefix of one that follows it.

ripgrep only supports "leftmost-first" match semantics. You can find a description of that semantic in the library documentation for ripgrep's default regex engine. PCRE2 will behave the same way.

The upside of leftmost-first is that it allows you to express a preference order. The downside is that it isn't commutative, as you've discovered.

It is conceivable that, in the far …

Replies: 2 comments 1 reply

Comment options

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

You must be logged in to vote
1 reply
@BurntSushi
Comment options

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