Regex find strings containing a sequence but not containing another sequence

How to write a regular expression to find all lines containing 665 and not having .pdf

I can't seem to find how not to work in regex. This is for Notepad ++ syntax, if that matters.

thank

+3
source share
2 answers

If it .pdfhappens only after 665, a negative statement 665(?!.*\.pdf)should work fine. Otherwise, I prefer to use two regular expressions, one for matching, one for rejection. In the Perl syntax:

/665/ && !/\.pdf/
+4
source

The function you are looking for is to look ahead.

665(?!.*\.pdf)
+2
source

Source: https://habr.com/ru/post/1698125/


All Articles