'negative' pattern matching in python
See it in action:
matchObj = re.search("^(?!OK|\\.).*", item)
Don't forget to put .*
after negative look-ahead, otherwise you couldn't get any match ;-)
if not (line.startswith("OK ") or line.strip() == "."):
print line
Use a negative match. (Also note that whitespace is significant, by default, inside a regex so don't space things out. Alternatively, use re.VERBOSE.)
for item in output:
matchObj = re.search("^(OK|\\.)", item)
if not matchObj:
print "got item " + item