Re: email format in python

2005-07-20 Thread dimitri pater
hello,
this one works quite well on validating email syntax:
http://www.secureprogramming.com/?action="">

regards,
DimitriOn 7/20/05, Dark Cowherd [EMAIL PROTECTED] wrote:
This seems to give reasonable results.import repattern = r'[EMAIL PROTECTED],4}\b'pattobj = re.compile(pattern)ps = pattobj.searchif ps(stringtocheck):But as lots of people have already told you on this list. This should
only be used to give a warning and not prevent the use of thatparticular address.DarkCowherd--http://mail.python.org/mailman/listinfo/python-list
-- Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: email format in python

2005-07-19 Thread Jorgen Grahn
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


Re: email format in python

2005-07-19 Thread Mike Meyer
Jorgen Grahn [EMAIL PROTECTED] 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 [EMAIL PROTECTED]

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

  mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: email format in python

2005-07-19 Thread Dark Cowherd
This seems to give reasonable results. 
import re
pattern = r'[EMAIL PROTECTED],4}\b'
pattobj = re.compile(pattern)
ps = pattobj.search 
if ps(stringtocheck):


But as lots of people have already told you on this list. This should
only be used to give a warning and not prevent the use of that
particular address.

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


Re: email format in python

2005-07-18 Thread Benji York
[EMAIL PROTECTED] wrote:
 I want to have the python equivalent function of this
 (that checks email format)
 
 function CheckEmail($Email = ) {
   if (ereg([[:alnum:[EMAIL PROTECTED]: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


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


Re: email format in python

2005-07-18 Thread Miki Tebeka
Hello met,

 I want to have the python equivalent function of this
 (that checks email format)
 
 function CheckEmail($Email = ) {
   if (ereg([[:alnum:[EMAIL PROTECTED]:alnum:]]+\.[[:alnum:]]+,
 $Email)) {
 return true;
   } else {
 return false;
   }
 }
Check out the email library module (see the examples at
http://docs.python.org/lib/node589.html)

Bye.
--

Miki Tebeka [EMAIL PROTECTED]
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys


pgpYVjP8OOEUV.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list