Here is a weird regular expression for emails .
We can have various kind of email addresses
The following regular expression can find any of the mails above
email2="[email protected]"
email1="[email protected]'"
email="[email protected]"
email3="[email protected]"
email4="[email protected]"
email5="[email protected]"
email6="[email protected]"
re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email)
x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email2)
x.group()
[email protected]'
x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email1)
x.group()
[email protected]'
x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email)
x.group()
'[email protected]'
This seems too complicated right...
I generalized it a bit....
x=re.search('(\w+[.|\w])*@(\w+[.])*\w+',email4)
x.group()
'[email protected]'
The above regular expression now can detect any type of combination...
Now if you want only email address ending with '.in' or '.com' then you can add a variation...
x=re.search('(\w+[.|\w])*@(\w+[.])*(com$|in$)',email)
You can try out this on various combinations.... If the expression does not fit anywhere , do tell me .
Some assumptions I have used : email address(username) wont contain special characters , only words or numbers.