import re
regex = re.compile(r"((((\+49(\s?))|(049(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(151|152|157|159|160|162|163|17)|((\+43(\s?))|(043(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(650|660|663|664|676|678|680|681|688|699)|((\+41(\s?))|(041(\s?))?)[.\-\\\/]*?((\(0\))|0)?\s?(76|77|78|79)))([ .\-\\\/]*[0-9]+){7,}", flags=re.MULTILINE)
test_str = ("===================================\n"
"====== sms phone ==================\n"
"===================================\n\n"
"Fon +49 33 27. 46 88 13\n"
"Fax +49 33 27. 46 88 46\n\n"
"+49 (0) 173 / 241 38 66\n\n"
"Neuenhofer Str. 6 Tel. 02244 - 8 79 96 39\n"
"53639 Königswinter Mobil: 0151 - 23 58 73 18\n\n"
"tel 030/ 5779 9182\n"
"fax 030/ 5779 9182\n"
"mob 0178/ 935 44 00\n\n"
"Tel. +49 (0) 9283 - 920 39 01\n"
"Fax +49 (0) 9283 - 920 391\n\n"
"Fon +99-99 99-9 9 99 99- 98\n"
"Mobil +49 - 177 - 999 99 99\n\n"
"Tel.: +49 (0) 99 99 - 77 999 777\n\n"
"0171 -99 99 99 99\n"
"0171 - 99 99 99 99\n\n"
"071195836855\n\n"
"210 Shepherd's Bush Road +49 30 340 604 760\n\n"
"+49 30 340 604 760\n\n"
"Phone: +49 177 2837460\n"
"ZAV Köln: +49 221 29304928\n\n"
"Tel +49 (0)8143 999500\n"
"Fax +49 (0)8143 999500\n"
"Mobil +49 (0)8143 999500\n\n"
"+49 (0) 6731 99 77 99 6\n\n"
"+49 173 9292927\n\n"
"+49 -(0) 173 9292927\n\n"
"Tel. 0621 939393 Memeler Straße 15\n"
"Fax 0283 9193940 67294 Mannheim-Schönau\n\n\n"
"+41 79 419 84 55\n\n"
"Tel. 02938 9987-12\n"
"Fax 02938 9987-12\n\n"
"030.20 14 32 34\n\n"
"Aparmenthotel ***** Telefon +49 (0) 9928 444 09-100\n\n"
"+49(0)23459302939577777\n\n\n"
"Mobil: +49 (0) 889 9999 9999\n\n\n"
"T: +43 (0)9999 99 999, F: +43 (0)9999 99 999-4\n\n"
"Tel.: +49 9999 9999999\n\n"
"Mobile (Mauritius): +230 00 00 00 00\n"
"Phone (Germany): +49 (351) 222 22 22\n\n"
"Telefon +49 99 99999-77777 92927 Berlin\n"
"Fax +49 99 99999-77777 Besucheranschrift:\n"
"Mobil +49 992 9999977777 Lichtenberger Straße 29 a\n\n"
"0171-99 99 99 99\n\n"
"040 6026770 s.goetze@provin.net\n"
"Mobil 0170-7934869 E-Email: leglos@athanasia-coaching.de\n\n"
"steffen.sprattler@consigno.net T+41 844 266 744\n\n"
"mobil: +23 (0) 234 342 kiel@h-faktor.de www.h-faktor.de\n\n\n")
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