import re
regex = re.compile(r"(?<=font-family:\")[^\"]+", flags=re.MULTILINE)
test_str = ("<body lang=EN-ZA style='tab-interval:36.0pt;word-wrap:break-word'>\n"
"<!--StartFragment--><span style='font-size:14.0pt;line-height:107%;\n"
"font-family:\"Comic Sans MS\";:\"Times New Roman\";\n"
":\"Times New Roman\";mso-font-kerning:0pt;mso-ligatures:none;\n"
"mso-ansi-language:EN-ZA;mso-fareast-language:EN-ZA;mso-bidi-language:AR-SA'>\n"
"Test Font 1\n"
" </span><span\n"
"style='font-size:14.0pt;line-height:107%;font-family:\"Boucherie Block\";\n"
":\"Times New Roman\";:\"Times New Roman\";\n"
"mso-font-kerning:0pt;mso-ligatures:none;mso-ansi-language:EN-ZA;mso-fareast-language:\n"
"EN-ZA;mso-bidi-language:AR-SA'>Test Font 2 </span><!--EndFragment-->\n"
"</body>")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
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