Regular expression is handy for extracting important part from a document or a string. Suppose you want to extract email id from a string then it can be easily done by '\S+@\S+' this expression. Where \S represents non-whitespace character, then followed by an @ sign and again by \S;as actually it is in a generic email id. So , let's get the code and extract email id -
import re
str = 'I have tried to email you at medhrk@gmail.com but it did not work so I send the mail to you by using your rediff account idhrk@rediffmail.com at @2PM'
lst = re.findall('\S+@\S+', str)
print lst
The output will be - ['medhrk@gmail.com',ídhrk@rediffmail.com],