Ripgrep with multiple pattern #1976
-
Hello, i am trying to use ripgrep with multiple patterns. I can achieve that with pattern1|pattern2 or the -e option. My problem is that i use the --json output and i want to know which pattern (pattern 1 or pattern2) matched my line. Is this somehow achievable? Thank you for you input. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, unfortunately ripgrep does not expose which pattern matched. It's possible this could be added some day, but it is quite a bit of work. There is also API design, since users could reasonably expect different semantics depending on what they're doing. For example, you might want to report all possible matches, even if they're overlapping. Or just report matches in the order in which patterns are given. If a pattern matches, then no other pattern could match at that span. |
Beta Was this translation helpful? Give feedback.
No, unfortunately ripgrep does not expose which pattern matched. It's possible this could be added some day, but it is quite a bit of work. There is also API design, since users could reasonably expect different semantics depending on what they're doing. For example, you might want to report all possible matches, even if they're overlapping. Or just report matches in the order in which patterns are given. If a pattern matches, then no other pattern could match at that span.