refactoring, improved string cleansing preprocessing

This commit is contained in:
Florian Förster
2024-05-31 09:59:22 +02:00
parent bb987e2108
commit 9cafc9fb97
13 changed files with 111 additions and 98 deletions

View File

@@ -0,0 +1,15 @@
import re
string = """
Hallo mein Name ist Max Mustermann und ich bin am 01.01.2024 geboren.
"""
patt = r'(\d{1,2}\.)?(\d{1,2}\.)([\d]{2,4})?'
patt2 = r'[ ]{2,}'
pattern = re.compile(patt)
pattern2 = re.compile(patt2)
res = pattern.sub('', string)
res = pattern2.sub(' ', res)
print(res)