Regular Expression Help Needed

Andrew Dalke dalke at dalkescientific.com
Sat Nov 17 12:01:20 EST 2001


William Park wrote [on auto-detecting email addresses using regexps]
>What's wrong with '[\w.]+@\w+(\.\w+)*' ?

The host name has to allow a '-' (it's A-Za-z90-9 and '-', but
not '_' as \w allows).

I am dalke at dalkescientific.com.  See the period at the end?
You don't want to grab that in your regexp.  Nor should you
grab two '.'s in a row.

The local address part (before the '@') could have '-' and
many other characters not included in the '[\w.]' you give.
Eg, is there anyone still using bang path notation?  (With '!'s
as extra routing information.)

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list