regex - Python match string if it does not start with X -


I want to find a file named "AcroTray.exe" on my disk. The program should print a warning if the file is located in any directory other than "distiller" I used the following syntax to match the negative

  (? ! Distillr)   

The problem is that though I "!" It always creates a match. I tried to understand the problem of using the eyewitness, but failed. This is what I tried to do:

  import re filePath = "C: \ Distillr \ AcroTray.exe" If re.search (r '(!! Distillr) \\ AcroTray \ .exe 'FilePath): Print "Match"   

This prints a match What's wrong with my regex?

I would like to get a match:

  C: \ SomeDir \ AcroTray.exe   

but not:

  c: \ distillr \ acroTray.exe    

negative Look-up ( (? & Lt ;! ... ), do not look at the negatives:

  if re.search ( R '(? & Lt;! Distillr) \\ AcroTray \ .exe, filePath):   

This mail:

  in [45] ]: Re-search (R '(? & Lt ;! Distiller) \\ AcroTray \ .exe', r'C: \ SomeDir \ AcroTray.exe ') Out [45]: & lt; _sre.SRE_Match 0xb57f448 & gt;   

This does not match:

 in  [46] ]: Re.search (r '(? & Lt ;! Distillr) \\ AcroTray \ .exe', R'C: \ Distillr \ AcroTray.exe ') # None    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -