[EMAIL PROTECTED] wrote:
> Does it really need to be a regular expression? Why not just write a
> short function that breaks apart the input and validates each part?
>
> def IsEmail(addr):
> 'Returns True if addr appears to be a valid email address'
>
> # we don't allow stuff like [EMAIL PROTECTED]@biff.com
> if addr.count('@') != 1:
> return False
> name, host = addr.split('@')
>
> # verify the hostname (is an IP or has a valid TLD, etc.)
> hostParts = host.split('.')
> ...
>
> That way you'd have a nice, readable chunk of code that you could tweak
> as needed (for example, maybe you'll find that the RFC is too liberal
> so you'll end up needing to add additional rules to exclude "bad"
> addresses).
>
Just to follow-up on this. I found that doing something such as this
along with a more generic RE that the results are much better. Thanks
for the idea!
--
http://mail.python.org/mailman/listinfo/python-list