On Mon, 18 Jul 2005 06:44:36 -0400, Benji York <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> I want to have the python equivalent function of this
>> (that checks email format)
>> 
...
>>   if (ereg("[[:alnum:[EMAIL PROTECTED]:alnum:]]+\.[[:alnum:]]+",
...
>
> While it is possible to translate the above code into Python (see 
> http://docs.python.org/lib/module-re.html), you should know that the 
> regex above will not validate all possible email addresses.

To be even more explicit about it, the regexp is extremely naive, and gives
the wrong results for a lot of common address formats -- not to mention for
even more uncommon formats. Do not use it, and do not try to modify it to
work!

> In general 
> it is a fools errand to try to anyway.

Agree. In the case of user input validation, it might be ok to politely
inform the user that the address looks a bit funny, but refusing to work
with it will anger a user sooner or later.

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/                algonet.se>   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to