import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^[\\dT:\\.+-]+\\s(?:aabvabcw74|aaxptac103).def.co.uk";
final String string = "2017-04-24T09:20:01.687387+00:00 aabvabcw74.def.co.uk hostd-probe:\n"
+ "2017-04-14T15:18:34.727042+00:00 Fri Apr 14 15:18:34 2017 aalesxbs029.def.co.uk lacp: DEBUG]:147, Recv signal 15, LACP service is about to stop\n"
+ "2017-04-24T09:20:01.687387+00:00 hostd probing is done. aabvabcw74.def.co.uk hostd-probe:\n"
+ "2017-04-24T20:53:29.334348+00:00 10.199.6.5 .def.co.uk aabvabcs15.def.co.uk Fdm: sslThumbprint>95:43:64:71:A3:60:D8:17:C8:6F:68:83:92:CE:E4:3B:53:4E:1D:AD10.199.6.5a2:0e:09:01:0a:00a2:0e:09:01:0b:01/vmfs/volumes/b01f388c-aaa4889f/vmfs/volumes/6ad2d8d7-86746df14435.5.03568722host-619286aabvabcs16.def.co.uk\n"
+ "2017-04-24T09:20:01.687387+00:00 aaxptac103.def.co.uk hostd-probe:";
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