How to find all emails (on the same line)

Fredrik Lundh fredrik at pythonware.com
Thu Jun 20 04:51:29 EDT 2002


"A" <printers at sendme.cz> wrote:

> I need to find ALL emails in a file.

that's about as vague as specifications come.  what kind
of mail?  what kind of file?  given that emails usually con-
sists of a couple of header lines followed by a body, what
kind of file can contain multiple mails on a single line? (etc)

> I can use re module but I do not know how to find all emails
> if there are more emails on the same  line because re module
> (as far as I know ) finds only one/first occurrence on that
> line.

use re.findall (or in recent versions, re.finditer)

</F>





More information about the Python-list mailing list