How to validate an email id using regular expression in Python?

PythonServer Side ProgrammingProgramming

The following code validates any given email id using regex in Python

Example

import re
s = 'manogna.neelam@tutorialspoint.com'
match = re.search(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', s, re.I)
print match.group()

Output

This gives the output

manogna.neelam@tutorialspoint.com
raja
Published on 11-Jan-2018 18:33:34
Advertisements