# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"[0-9]"
test_str = ("WEBVTT\n\n"
"NOTE duration:\"02:09:15.8840000\"\n\n"
"NOTE language:en-us\n\n"
"NOTE Confidence: 0.881069481372833\n\n"
"d8d8fcb9-ccb1-41f2-a75e-0c3088e95dc2\n"
"00:00:01.720 --> 00:00:07.798\n"
"So we're going\n"
"to try to\n\n"
"NOTE Confidence: 0.881069481372833\n\n"
"a8f8cc83-48c4-4acc-881b-85b37c73b42c\n"
"00:00:07.798 --> 00:00:13.876\n"
"to use Microsoft\n"
"Teams next week,\n\n"
"NOTE Confidence: 0.881069481372833\n\n"
"d2738b5d-b7ee-4b58-8388-4b7524c3c563\n"
"00:00:13.876 --> 00:00:19.954\n"
"so will post\n"
"it as a\n\n"
"NOTE Confidence: 0.802268326282501\n\n"
"baab9c8e-f018-48a2-a355-b23eb29174e9\n"
"00:00:19.954 --> 00:00:25.728\n"
"teams meeting. If you've never\n"
"used prosoft teams before, it's\n\n"
"NOTE Confidence: 0.932209372520447\n\n"
"73231caa-7ae7-4046-acdf-c6691c7c3c41\n"
"00:00:25.728 --> 00:00:30.013\n"
"it's. Basically the same thing,\n"
"just a little more stable.\n\n"
"NOTE Confidence: 0.825244784355164\n\n"
"3ab6c4cb-9d70-4140-8356-c0f7c2316874\n"
"00:00:30.730 --> 00:00:35.224\n"
"Then they will put the link in\n"
"Quercus and send it out as an")
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