OT: regex to find email
Robert Brewer
fumanchu at amor.org
Tue Sep 21 11:18:55 EDT 2004
Remy Blank wrote:
> 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.
Yes, but if you use the [a-z] charset instead of using \w, remember to
use the case-insensitive flag when you compile your regex.
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list