forked from Tanmay-901/python-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemailchecker.py
40 lines (28 loc) · 879 Bytes
/
emailchecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Python program to validate an Email
# import re module
# re module provides support
# for regular expressions
import re
# Make a regular expression
# for validating an Email
regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
# for custom mails use: '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w+$'
# Define a function for
# for validating an Email
def check(email):
# pass the regular expression
# and the string in search() method
if(re.search(regex,email)):
print("Valid Email")
else:
print("Invalid Email")
# Driver Code
if __name__ == '__main__' :
# Enter the email
email = "[email protected]"
# calling run function
check(email)
email = "[email protected]"
check(email)
email = "ankitrai326.com"
check(email)