Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- """
- Написати програму яка запитує у користувача його email адресу, та
- перевіряє чи це коректна адреса. Тобто чи задана стрічка відповідає
- вимогам електронної адреси.
- ---------------------------
- Simplified rules are used for verification:
- - uppercase and lowercase Latin letters A to Z and a to z;
- - digits 0 to 9;
- - dot ., provided that it is not the first or last character unless quoted
- - hyphen -, provided that it is not the first or last character.
- """
- import re
- answer = input('Please enter your email address: ')
- regex = re.compile(
- """
- ^[A-Z0-9]{1}[A-Z0-9.-]*[A-Z0-9]{1} #Check local-part email
- @
- [A-Z0-9]{1}[A-Z0-9.-]*[A-Z0-9]{1} #Check domain name part email
- \.[A-Z]{2,}
- """ , re.I|re.X)
- email = re.search(regex, answer)
- if email:
- print(f'Your email {email[0]} is correct')
- else:
- print('Your email is incorrect')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement