Tags


>>> import re
>>> line = "why people don't know what regex are? let me know ananthu@epillars.com.lol"
>>> match = re.search(r'[\w\.-]+@[\w\.-]+', line)
>>> match.group(0)
'ananthu@epillars.com.lol'

If you have several email addresses use findall:

>>> line = "why people don't know what regex are? let me know 321dsasdsa@dasdsa.com.lol   dssdadsa dadaads@dsdds.com"
>>> match = re.findall(r'[\w\.-]+@[\w\.-]+', line)
>>> match
['321dsasdsa@dasdsa.com.lol', 'dadaads@dsdds.com']
Advertisements