On Jul 2, 12:41 pm, Sallu <[EMAIL PROTECTED]> wrote:
> Hi All,   import re
> msg=raw_input('Enter the email : ')
>
> def validateEmail(email):
>
>         #if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]
> {1,3})(\\]?)$", email) != None:
>         if re.match("^([EMAIL PROTECTED])@((?:[-a-z0-9]+\.)+[a-z]{2,})$",
> email) != None:
>                 print 'Valis'
>         else:
>                 print 'not'
>
> validateEmail(msg)  i wrote a script above it works fine but it does
> not check for valid domain like .com .org .in
> how to validate with domain

Don't try and check that the TLD (.com .org etc.) is valid with a
regular expression.

Just don't.

Especially now that the rules about domain names are now being relaxed
and there is no possible way of you predicating what all the new TLDs
will be.

Validating that that the e-mail address is in a valid form, and
validating the domain is valid are two separate things.

If you want to validate the domain, do a DNS lookup on the domain or
some such. I don't think there are standard modules to provide this
functionality included with python. You could try using the socket
module, and reading up on the relevant protocols, or making calls to
external programs.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to