views:

961

answers:

2

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

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

Thanks

+1  A: 

The feature you'r looking for is look ahead patterns

665(?!.*\.pdf)
John Nilsson
That won't work if the ".pdf" precedes the "665" (which may or may not matter to the original poster).
Michael Carman
+3  A: 

If .pdf will only occur after 665, the negative lookahead assertion 665(?!.*\.pdf) should work fine. Otherwise, I prefer to use two regexs, one to match, one to fail. In Perl syntax that would be:

/665/ && !/\.pdf/
Dov Wasserman