import re
regex = re.compile(r"^([a-zäöüÄÖÜß\s\d.,-]+?)\s*([\d\s]+(?:\s?[-|+\/]\s?\d+)?\s*[a-z]?)?\s*(\d{5})\s*(.+)?$", flags=re.MULTILINE | re.IGNORECASE)
test_str = ("Gewerbegebiet Ziesegrund 17440 Hohendorf bei Wolgast\n"
"Sonnenwiechser Str. 42 1/2 83052 Bruckmühl, Mangfall\n"
"Am Hamberg 4/1 79400 Kandern\n"
"Brüggerfeld 14 + 20 29574 Ebstorf\n"
"Straße des 17. Juni 18+19 88485 Berlin\n"
"Hochstr. 19 88045 Friedrichshafen\n"
"Straße des 17. Juni 23-25 a 12345 Berlin-Mitte\n"
"Domerschulstrasse 234 34070 Verlin\n"
"ERDINGERSTR.32 84405 DORFEN\n"
"GRüNERSTR. 14 A 67061 LUDWIGSHAFEN\n"
"KÖNIGSWINTER STR. 120 53227 BONN\n"
"GRÜNER WEG 11A\n"
"ERDINGERSTR.32 2443 DORFEN\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