Parsing for email addresses

Ben Finney ben+python at benfinney.id.au
Mon Feb 15 20:01:03 EST 2010


galileo228 <mattbarkan at gmail.com> writes:

> I'm trying to write python code that will open a textfile and find the
> email addresses inside it. I then want the code to take just the
> characters to the left of the "@" symbol, and place them in a list.

Email addresses can have more than one ‘@’ character. In fact, the
quoting rules allow the local-part to contain *any ASCII character* and
remain valid.

> Any suggestions would be much appeciated!

For a brief but thorough treatment of parsing email addresses, see RFC
3696, “Application Techniques for Checking and Transformation of Names”
<URL:http://www.ietf.org/rfc/rfc3696.txt>, specifically section 3.

-- 
 \          “What I have to do is see, at any rate, that I do not lend |
  `\      myself to the wrong which I condemn.” —Henry Thoreau, _Civil |
_o__)                                                    Disobedience_ |
Ben Finney



More information about the Python-list mailing list