Parsing for email addresses
jgardner at jonathangardner.net
Tue Feb 16 00:49:31 CET 2010
On Feb 15, 3:34 pm, galileo228 <mattbar... at gmail.com> wrote:
> 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.
> (So if galileo... at gmail.com was in the file, 'galileo228' would be
> added to the list.)
> Any suggestions would be much appeciated!
You may want to use regexes for this. For every match, split on '@'
and take the first bit.
Note that the actual specification for email addresses is far more
than a single regex can handle. However, for almost every single case
out there nowadays, a regex will get what you need.
More information about the Python-list