OT: regex to find email

Remy Blank remy.blank_asps at pobox.com
Tue Sep 21 11:08:47 EDT 2004


Josh Close wrote:
> I've been trying to find a good regex to parse emails, but haven't
> found any to my liking. I basically need to have
> 
> ( r'[a-z0-9\.\-\_]@[a-z0-9\.\-\_]', re.IGNORECASE )
> 
> but the first part can't start with .-_ and the last part has to have
> a . in it (first/last being before/after the @).

I'd try something like (untested):

[a-z0-9][a-z0-9\._-]*@[a-z0-9\._-]+\.[a-z0-9\._-]+

Basically, you have to remember to say *how many* characters you want
of a specific set, that's what the '*' and '+' are for.

-- Remy


Remove underscore and suffix in reply address for a timely response.




More information about the Python-list mailing list