# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^(?!.*(?:is OK|is a broken|file could not be opened)).*"
test_str = ("eth0\n"
"10.0.11.196\n"
"00:0C:29:AF:6A:A7\n"
"parameters passed to uvscan: --DRIVER /opt/McAfee/uvscan/datfiles/current -- ANALYZE --AFC=32 ATIME-PRESERVE --PLAD --RPTALL RPTOBJECTS SUMMARY --UNZIP -- RECURSIVE --SHOWCOMP --MIME --THREADS=4 /tmp\n"
"temp XML output is: /tmp/HIQZRq7t2R\n"
"McAfee VirusScan Command Line for Linux64 Version: 6.0.5.614\n"
"Copyright (C) 2014 McAfee, Inc.\n"
"(408) 988-3832 LICENSED COPY - April 03 2016\n\n"
"AV Engine version: 5700.7163 for Linux64.\n"
"Dat set version: 8124 created Apr 3 2016\n"
"Scanning for 670707 viruses, trojans and variants.\n\n\n"
"No file or directory found matching /root/SVN/swd-lhn-build/trunk/utils/ATIME-PRESERVE\n\n"
"No file or directory found matching /root/SVN/swd-lhn-build/trunk/utils/RPTOBJECTS\n\n"
"No file or directory found matching /root/SVN/swd-lhn-build/trunk/utils/SUMMARY\n"
"/tmp/tmp.BQshVRSiBo ... is OK.\n"
"/tmp/keyring-F6vVGf/socket ... file could not be opened.\n"
"/tmp/keyring-F6vVGf/socket.ssh ... file could not be opened.\n"
"/tmp/keyring-F6vVGf/socket.pkcs11 ... file could not be opened.\n"
"/tmp/yum.log ... is OK.\n"
"/tmp/tmp.oW75zGUh4S ... is OK.\n"
"/tmp/.X11-unix/X0 ... file could not be opened.\n"
"/tmp/tmp.LCZ9Ji6OLs ... is OK.\n"
"/tmp/tmp.QdAt1TNQSH ... is OK.\n"
"/tmp/ks-script-MqIN9F ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/mcupgrade.conf ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/uninstall-uvscan ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/mcscan ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/install-uvscan ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/readme.txt ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/uvscan_secure ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/signlic.txt ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/uvscan ... is OK.\n"
"/tmp/tmp.mHXPvYeKjb/uvscan/liblnxfv.so.4 ... is OK.")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html