email format in python

Benji York benji at benjiyork.com
Mon Jul 18 12:44:36 CEST 2005


met at n wrote:
> I want to have the python equivalent function of this
> (that checks email format)
> 
> function CheckEmail($Email = "") {
>   if (ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+",
> $Email)) {
>     return true;
>   } else {
>     return false;
>   }
> }

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.  In general 
it is a fools errand to try to anyway.
--
Benji York





More information about the Python-list mailing list