From 4dc3ee33b42e3f775256c1389a12f81420a1bc4d Mon Sep 17 00:00:00 2001 From: roshitha2707 <72878563+roshita2707@users.noreply.github.com> Date: Wed, 27 Oct 2021 09:01:18 -0700 Subject: [PATCH] Email_Validation To check whether the given email is valid or not by using python . --- python/Email_Validation.py | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 python/Email_Validation.py diff --git a/python/Email_Validation.py b/python/Email_Validation.py new file mode 100644 index 0000000..a57f256 --- /dev/null +++ b/python/Email_Validation.py @@ -0,0 +1,41 @@ +# 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 = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' + +# Define a function for +# for validating an Email + + +def check(email): + + # pass the regular expression + # and the string into the fullmatch() method + if(re.fullmatch(regex, email)): + print("Valid Email") + + else: + print("Invalid Email") + + +# Driver Code +if __name__ == '__main__': + + # Enter the email + email = "ankitrai326@gmail.com" + + # calling run function + check(email) + + email = "my.ownsite@our-earth.org" + check(email) + + email = "ankitrai326.com" + check(email)