I am trying to use a regex that does the following: matches any text without the word "Chrome", followed by the word "Safari"
I have compiled a python script that does not work.
#!/usr/bin/env python import sys import re # any text but 'Chrome' followed by Safari negative_re = re.compile( '(?<!Chrome).*?Safari' ) matcher = negative_re.search( sys.argv[1] ) if matcher: print "match" else: print "no match"
I tried the following examples
test_negative.py "Chrome Mobile/12345 Safari" > match test_negative.py "Like MAC OS Safari" > match
I was hoping that the first would return “no match,” and the second would return “match.” If someone can help with regex, that would be great, thanks.
source share