import re
regex = re.compile(r"href\=\"([^\"]*)\"", flags=re.MULTILINE)
test_str = ("<hr />\n"
"<ul>\n"
"<li><strong>خالد المشيقح:</strong></li>\n"
"</ul>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/01.mp3\">شرح التسهيل 1 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/02.mp3\">شرح التسهيل 2 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/03.mp3\">شرح التسهيل 3</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/04.mp3\">شرح التسهيل 4</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/05.mp3\">شرح التسهيل 5 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/06.mp3\">شرح التسهيل 6</a></p>\n"
"<ul>\n"
"<li><strong>عبدالسلام الشويعر:</strong></li>\n"
"</ul>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/07.mp3\">شرح التسهيل 7</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/08.mp3\">شرح التسهيل 8 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/09.mp3\">شرح التسهيل 9 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/10.mp3\">شرح التسهيل 10</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/11.mp3\">شرح التسهيل 11 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/12.mp3\">شرح التسهيل 12 </a></p>\n"
"<ul>\n"
"<li><strong>سامي الصقير:</strong></li>\n"
"</ul>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/13.mp3\">شرح التسهيل 13 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/14.mp3\">شرح التسهيل 14 </a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/15.mp3\">شرح التسهيل 15</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/16.mp3\">شرح التسهيل 16</a></p>\n"
"<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/17.mp3\">شرح التسهيل 17 </a></p>\n"
"<hr />")
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