-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathemailchecker_regex.py
More file actions
40 lines (28 loc) · 880 Bytes
/
emailchecker_regex.py
File metadata and controls
40 lines (28 loc) · 880 Bytes
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 = "dude_tanmay326@gmail.com"
# calling run function
check(email)
email = "my.ownsite@ourearth.org"
check(email)
email = "ankitrai326.com"
check(email)