How does one match a pattern unless it is part of a bigger pattern? #2975
-
I would like to match patterns unless they are part of bigger patterns. I have looked at the rg the man pages, issues, discussions general regex docs and elsewhere and was not able to find an answer for this. It is possible I missed it. The purpose of this is to look for values that should be redacted while ignoring common false positives.
Example: match a social security number unless it is in a SHA1SUM, so no match should be produced for this example.
SHA1SUM_PATTERN:
Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The standard technique here is to use shell pipelines. For example,
Makes using shell pipelines pretty hard. At least, I can't think of a simple approach other than using |
Beta Was this translation helpful? Give feedback.
-
It's worth pointing out here that you could write a very simple Rust program using the |
Beta Was this translation helpful? Give feedback.
The standard technique here is to use shell pipelines. For example,
rg '\w{10}' | rg -v foo
. But, this requirement: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.