I want to find a file called "AcroTray.exe" on my disk. The program should print a warning if the file is in a directory other than "Distillr" . I used the following syntax to do a negative match
(?!Distillr)
The problem is that although I use "!" he always produces MATCH. I tried to find out the problem using IPython but could not. This is what I tried:
import re
filePath = "C:\Distillr\AcroTray.exe"
if re.search(r'(?!Distillr)\\AcroTray\.exe', filePath):
print "MATCH"
He is typing MATCH. What is wrong with my regex?
I would like to get a match:
C:\SomeDir\AcroTray.exe
But not on:
C:\Distillr\AcroTray.exe
source
share