Computer >> Computer tutorials >  >> Programming >> Python

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


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

Example

import re
s = '[email protected]'
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

[email protected]