I\'m trying to extract email addresses from plain text transcripts of emails. I\'ve cobbled together a bit of code to find the addresses themselves, but I don\'t know how to mak
Try this out:
>>> from email.utils import parseaddr
>>> parseaddr('From: vg@m.com')
('', 'vg@m.com')
>>> parseaddr('From: Van Gale ')
('Van Gale', 'vg@m.com')
>>> parseaddr(' From: Van Gale ')
('Van Gale', 'vg@m.com')
>>> parseaddr('blah abdf From: Van Gale and this')
('Van Gale', 'vg@m.com')
Unfortunately it only finds the first email in each line because it's expecting header lines, but maybe that's ok?