import re
regex = re.compile(r"(\<\!\-{2})([a-z\ ]*)(\-{2}\>)", flags=re.IGNORECASE | re.MULTILINE)
test_str = ("<header class=\"noSelect\">\n"
" <div id=\"HIAccueil\" class=\"I-B\">\n"
" <img class=\"pointer\" src=\"IMG/BACKGROUND/HEADER/logoban.png\" alt=\"Accueil\" onclick=\"clickMenu(tousLesMenus, 2, tousLesMenus[0].nom, 1, 0, 0, 0, tousLesMenus[1].url);\">\n"
" </div>\n"
" <div id=\"HIPC\">\n"
" <div id=\"HIProfile\" class=\"I-B\">\n"
" <!-- vide pour img via js -->\n"
" </div>\n"
" <div id=\"HIConnect\" class=\"I-B\">\n"
" <img class=\"pointer\" src=\"IMG/BACKGROUND/HEADER/connect_hover.gif\" alt=\"Connect\" onclick=\"clickMenu(tousLesMenus, 5, tousLesMenus[0].nom, 4, 1, 1, 0, tousLesMenus[4].url);\">\n"
" </div>\n"
" </div>\n"
"</header>\n"
"Tralloc_Nivek-02.baza_R-d421@gmail45.com\n"
"Tralloc_Nivek-02@gmail45.com\n"
"Tralloc_Nivek-02.baza_R-d421gmail45.c\n\n"
"010/226679\n"
"010226679\n"
"010/22.66.79\n"
"010/22 66 79\n"
"0470040747\n"
"0470/040747\n"
"0470/040.747\n"
"0470/04.07.47\n"
"0470/04 07 47\n"
"0470/040 747\n"
"+0032470040747\n"
"0032470/040 747\n"
"+00320470040747")
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