Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created May 25, 2016 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonty/a42e8c023583f7febd0dffc7ab9f5021 to your computer and use it in GitHub Desktop.
Save Jonty/a42e8c023583f7febd0dffc7ab9f5021 to your computer and use it in GitHub Desktop.
import re
for example in ("fooBarIgnoreThis", "fooBarThis"):
# Zero width negative lookbehind!
if re.search("(?<!Ignore)This", example):
print "Matched", example
else:
print "Did not match", example
(sandbox)jonty@towel:~/sandbox $ python ignorethis.py
Did not match fooBarIgnoreThis
Matched fooBarThis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment