Bruce Eckels gave me this. It has been working very fine for me. Peter def ShouldBeNone(result): return result is not None def ShouldNotBeNone(result): return result is None tests = ( (re.compile("^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-]+$"), ShouldNotBeNone, "Fail$ (re.compile("^[^0-9a-zA-Z]|[^0-9a-zA-Z]$"), ShouldBeNone, "Failed b"), (re.compile("([0-9a-zA-Z]{1})\@."), ShouldNotBeNone, "Failed c"), (re.compile(".\@([0-9a-zA-Z]{1})"), ShouldNotBeNone, "Failed d"), (re.compile(".\.\-.|.\-\..|.\.\..|.\-\-."), ShouldBeNone, "Failed e"), (re.compile(".\.\_.|.\-\_.|.\_\..|.\_\-.|.\_\_."), ShouldBeNone, "Failed f"), (re.compile(".\.([a-zA-Z]{2,3})$|.\.([a-zA-Z]{2,4})$"), ShouldNotBeNone, "Fai$) def ValidEmailAddress(address, debug=None): for test in tests: if test[1](test[0].search(address)): if debug: return test[2] return 0 return 1 On Friday 12 April 2002 07:19, Michael Fox wrote:
Hi *,
Not being a python guru myself, I was wondering if anyone could provide a code snippet that checks the value of a dtml-var to see if it's a valid email address..?
Cheers,
Michael Fox
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )