Generic Regex: Find a file that never contains a line that matches a specific expression
PeterJones last edited by
There are times you want to find out if a file never has a line that matches a specific expression.
Using Regular Expression mode in the Find in Files dialog, you could use
- FIND =
Here, DNM means “does not match”, and is any regular expression which should not be found as a complete line anywhere in the file
For example, to find any files that don’t contain
George, you would substitute
Georgein for DNM in the expression,
(?i-s)\A(^(?!George).*$\R*)+\z, and then run the Find in Files with that find expression. If the file has
George, it will not show up in the Find Results. If a file does not contain
George, then the first line of the file will show up in the Find Results panel.
Originally developed in developing generic regex sequences and subsequent discussion
For other generic expressions, see FAQ Desk: Generic Regular Expression (regex) Formulas
- FIND =