Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: email format in python

Reply
Thread Tools

Re: email format in python

 
 
Benji York
Guest
Posts: n/a
 
      07-18-2005
met@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


 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      07-19-2005
On Mon, 18 Jul 2005 06:44:36 -0400, Benji York <(E-Mail Removed)> wrote:
> met@n wrote:
>> I want to have the python equivalent function of this
>> (that checks email format)
>>

....
>> if (ereg("[[:alnum:]]+@[[: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!
 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      07-20-2005
Jorgen Grahn <(E-Mail Removed)> writes:
> 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.


Yup. I use cryptographically signed addresses as one-time addresses
for web forms. They look like http://www.velocityreviews.com/forums/(E-Mail Removed).

It really annoys me when some site decides that that can't be my real
email address.

<mike
--
Mike Meyer <(E-Mail Removed)> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Detecting Email Message File Format & Support for EMLX Format sherazam Java 0 02-09-2012 08:29 AM
how to get the correct email format when sending email using sqldatareader rote ASP .Net 8 04-17-2008 02:14 AM
Re: Python's email module - problem with umlauts in some email clients Fredrik Lundh Python 0 12-08-2006 03:22 PM
Python's email module - problem with umlauts in some email clients Nico Grubert Python 0 12-08-2006 03:17 PM
email format in python met@n Python 0 07-18-2005 10:21 AM



Advertisments