E-Mail Validation Using Regular Expressions in Python

 E-Mail Validation Using Regular Expressions in Python


A Python Program to validate E-Mail using RegEx

# import regular expression module

import re
# making regular expressions
regexpression=r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Z|a-z]{2,}\b'
#Defining function for email validation
def evalidation(email):
    #pass regular expression 
    if(re.fullmatch(regexpression,email)):
        print("Email is valid")
    else:
        print("Email is not valid")
email='drmanishamore8@gmail.com'
evalidation(email)
email="mayu_madhu@rediffmail.com"
evalidation(email)
email="manisha more"
evalidation(email)

O/P:
Email is valid Email is valid Email is not valid




A Python program to validate email using RegExp. Input email through keyboard

#email Validation
# import regular expression module
import re
# making regular expressions
regexpression=r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9._]+\.[A-Z|a-z]{2,}\b'
# Input string
email=str(input("Enter Email\n"))
#Defining function for email validation
def evalidation(email):
    #pass regular expression 
    if(re.fullmatch(regexpression,email)):
        print("Email is valid")
    else:
        print("Email is not valid")
evalidation(email)

O/P:
Enter Email sfgh Email is not valid


टिप्पणी पोस्ट करा

0 टिप्पण्या