# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^[\dT:\.+-]+\s(?:aabvabcw74|aaxptac103).def.co.uk"
test_str = ("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:")
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