z.B._pr3_skriptspr_team12_s2/s2_a4_a.py

16 lines
350 B
Python
Raw Normal View History

2023-01-09 14:25:06 +01:00
import re
def normalize(number):
pattern = re.compile(r'\+?1?.?.?([2-9]\d{2}).?.?(\d{3}).?([2-9][0-8]\d{2}$)')
tmp = pattern.match(number)
if(tmp):
return '1' + '-' + tmp.group(1) + '-' + tmp.group(2) + '-' + tmp.group(3)
else: raise ValueError('Ungültige Telefonnummer')
bruh = normalize("1-989-111-2222")
print(bruh)