import re falsch = "If the the problem is textual, use the the re module" richtig = re.sub(r"the (the)", r"\1", falsch) print(richtig) test = "Ingeborg Sülzer-Toft" match = re.search(r"(.*?)\.", test) if match: name = re.sub(r"([A-Za-zäöüÄÖÜ]+).([A-Za-zäöüÄÖÜ]-+) ([A-Za-zäöüÄÖÜ]-+)(?: ([A-Za-zäöüÄÖÜ]-+))?", r"\1 \2 \3 \4", test) #Titel (optional), Vorname, Zweitname (optional) und Nachname parts = name.split() print("1= ", parts[0]) print("2= ", parts[1]) if len(parts) == 3: print("3= ", parts[2]) if len(parts) == 4: print("4= ", parts[3])