30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import regex as re
|
|
|
|
|
|
def is_name_correct(name: str) -> bool:
|
|
result = re.match(r'^(\p{Lu}|\p{Lt}).+$', name)
|
|
return True if result else False
|
|
|
|
|
|
def is_phone_correct(name: str) -> bool:
|
|
result = re.match(r'^\(\d{2}\)\s*\d{3}-\d{2}-\d{2}', name)
|
|
return True if result else False
|
|
|
|
|
|
def is_zipcode_correct(name: str) -> bool:
|
|
result = re.match(r'^\d{2}-\d{3}$', name)
|
|
return True if result else False
|
|
|
|
|
|
first_name = input("Poda imie: ")
|
|
second_name = input("Poda nazwisko: ")
|
|
city = input("Poda nazwe miasta: ")
|
|
phone_number = input("Poda numer telefonu: ")
|
|
zip_code = input("Poda kod pocztowy: ")
|
|
|
|
print("Imie poprawne!") if is_name_correct(first_name) else print("Imie niepoprawne!")
|
|
print("Nazwisko poprawne!") if is_name_correct(second_name) else print("Nazwisko niepoprawne!")
|
|
print("Miasto poprawne!") if is_name_correct(city) else print("Miasto niepoprawne!")
|
|
print("Telefon poprawny!") if is_phone_correct(phone_number) else print("Telefon niepoprawny!")
|
|
print("Kod pocztowy poprawny!") if is_zipcode_correct(zip_code) else print("Kod pocztowy niepoprawny!")
|