import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(?!.*(?:is OK|is a broken|file could not be opened)).*";
final String string = "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.";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html