I'm new to Python 2.7. Using regular expressions, I'm trying to extract from a text file just the emails from input lines. I am using the non-greedy method as the emails are repeated 2 times in the same line. Here is my code:
import re
f_hand = open('mail.txt')
for line in f_hand:
line.rstrip()
if re.findall('\S+@\S+?',line): print re.findall('\S+@\S+?',line)
however this is what i"m getting instead of just the email address:
['href="mailto:secretary@abc-mediaent.com">sercetary@a']
What shall I use in re.findall
to get just the email out?