# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"Category2-{25}\n.+Account\s+(.+)[\s\S]+?High Score = (.+)"
test_str = ("\n"
"2019-10-17 17:56:44,295 :: INFO :: root :: -------------------------Category1-------------------------\n"
"2019-10-17 17:56:49,988 :: INFO :: root :: Account 12345@email.com...\n"
"2019-10-17 17:57:09,328 :: INFO :: root :: other info 1\n"
"2019-10-17 18:00:22,267 :: INFO :: root :: other info 2\n"
"2019-10-17 18:00:22,582 :: INFO :: root :: High Score = 19090\n"
"2019-10-17 18:00:22,582 :: INFO :: root :: other info 3\n"
"2019-10-17 18:00:22,582 :: INFO :: root :: other info 4\n"
"2019-10-17 18:00:24,661 :: INFO :: root :: -------------------------Category2-------------------------\n"
"2019-10-17 18:00:29,619 :: INFO :: root :: Account 12345@email.com...\n"
"2019-10-17 18:00:46,317 :: INFO :: root :: other info 1\n"
"2019-10-17 18:05:46,088 :: INFO :: root :: other info 2\n"
"2019-10-17 18:05:52,451 :: INFO :: root :: other info 3\n"
"2019-10-17 18:08:11,765 :: INFO :: root :: other info 4\n"
"2019-10-17 18:08:12,813 :: INFO :: root :: High Score = 19290\n"
"2019-10-17 18:08:12,814 :: INFO :: root :: other info 5\n"
"2019-10-17 18:08:12,814 :: INFO :: root :: other info 6\n"
"2019-10-17 18:08:14,890 :: INFO :: root :: -------------------------Category1-------------------------\n"
"2019-10-17 18:08:19,860 :: INFO :: root :: Account 45678@email.com...\n"
"2019-10-17 18:08:37,188 :: INFO :: root :: other info 1\n"
"2019-10-17 18:13:23,232 :: INFO :: root :: other info 2\n"
"2019-10-17 18:13:23,595 :: INFO :: root :: High Score = 23425\n"
"2019-10-17 18:13:23,595 :: INFO :: root :: other info 3\n"
"2019-10-17 18:13:23,595 :: INFO :: root :: other info 4\n"
"2019-10-17 18:13:25,689 :: INFO :: root :: -------------------------Category2-------------------------\n"
"2019-10-17 18:13:30,660 :: INFO :: root :: Account 45678@email.com...\n"
"2019-10-17 18:13:47,727 :: INFO :: root :: other info 1\n"
"2019-10-17 18:16:20,327 :: INFO :: root :: other info 2\n"
"2019-10-17 18:16:26,907 :: INFO :: root :: other info 3\n"
"2019-10-17 18:18:44,376 :: INFO :: root :: other info 4\n"
"2019-10-17 18:18:45,447 :: INFO :: root :: High Score = 23625\n"
"2019-10-17 18:18:45,447 :: INFO :: root :: other info 5\n"
"2019-10-17 18:18:45,447 :: INFO :: root :: other info 6")
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