codefire wrote:
> Hi,
>
> thanks for the advice guys.
>
> Well took the kids swimming, watched some TV, read your hints and
> within a few minutes had this:
>
> r = re.compile(r'[EMAIL PROTECTED]@\s]+\.\w+')
>
> This works for me. That is if you have an invalid email such as
> tony..bATblah.com it will reject it (note the double dots).
>
> Anyway, now know a little more about regexps :)

A little more is unfortunately not enough. The best advice you got was
to use an existing e-mail address validator. The definition of a valid
e-mail address is complicated. You may care to check out "Mastering
Regular Expressions" by Jeffery Friedl. In the first edition, at least
(I haven't looked at the 2nd), he works through assembling a 4700+ byte
regex for validating e-mail addresses. Yes, that's 4KB.  It's the best
advertisement for *not* using regexes for a task like that that I've
ever seen.

Cheers,
John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to