# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?s)Director(.*?)Class"
test_str = ("[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/901.html\n"
"\"Blaine County 24h North\"\n"
"Director\n"
"9Jeremiah9\n"
"Class\n"
"Classic Sports B\n"
"Weather\n"
"CLEAR\n"
"Laps\n"
"7\n"
"Start\n"
"04/17/2019 18:14:34\n"
"Duration\n"
"11 minutes\n"
"1st\n"
"Nolan North\n"
"2nd\n"
"aharmlesscat\n"
"3rd\n"
"Subaruken\n\n"
"[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/902.html\n"
"\"CRE8 - Mercedes Autodrome\"\n"
"Director\n"
"9Jeremiah9\n"
"Class\n"
"Modern Muscle\n"
"Weather\n"
"CLEAR\n"
"Minutes\n"
"10\n"
"Start\n"
"04/17/2019 18:30:59\n"
"Duration\n"
"13 minutes\n"
"1st\n"
"Subaruken\n"
"2nd\n"
"Elbererth\n"
"3rd\n"
"CSP\n\n"
"[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/903.html\n"
"\"SCRZ Monte verde\"\n"
"**Time Attack**\n"
"Director\n"
"Elbererth\n"
"Class\n"
"Supers\n"
"Weather\n"
"CLEAR\n"
"Laps\n"
"7\n"
"Start\n"
"04/17/2019 18:46:41\n"
"Duration\n"
"12 minutes\n"
"1st\n"
"Elbererth\n"
"2nd\n"
"Subaruken\n"
"3rd\n"
"bvneet\n\n"
"[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/904.html\n"
"\"LS Gas GP\"\n"
"Director\n"
"9Jeremiah9\n"
"Class\n"
"Muscle\n"
"Weather\n"
"CLEAR\n"
"Minutes\n"
"10\n"
"Start\n"
"04/17/2019 19:09:06\n"
"Duration\n"
"12 minutes\n"
"1st\n"
"Elbererth\n"
"2nd\n"
"Olli399\n"
"3rd\n"
"Epic gamer\n\n"
"[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/905.html\n"
"\"FISH Plastic Beach\"\n"
"Director\n"
"lodus\n"
"Class\n"
"Sport Sedans\n"
"Weather\n"
"CLEAR\n"
"Minutes\n"
"12\n"
"Start\n"
"04/17/2019 19:28:29\n"
"Duration\n"
"15 minutes\n"
"1st\n"
"Elbererth\n"
"2nd\n"
"bvneet\n"
"3rd\n"
"aharmlesscat\n\n"
"[18-Apr-19 05:54 PM] Charliebot#6692\n\n\n"
"{Embed}\n"
"Race Result\n"
"http://inssomniak.5gbfree.com/RaceResult/906.html\n"
"\"Northwick GP Update\"\n"
"Director\n"
"lodus\n"
"Class\n"
"Testing\n"
"Weather\n"
"CLEAR\n"
"Minutes\n"
"12\n"
"Start\n"
"04/17/2019 19:48:33\n"
"Duration")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.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