Rich,

> But for some reason it insists that rich&[EMAIL PROTECTED]
> is NOT a bad email, despite the [-\._a-z0-9]* clearly stating
> that ampersands are not allowed. whaddafug? 

The regex is doing exactly what you've told it to do:

[a-z0-9]       Match exactly one alpha/number
[-\._a-z0-9]*  Match zero or more alpha/number/dot/underscore/hyphen

With the email address rich&[EMAIL PROTECTED] it's basically ignoring
the "rich&" bit and matching on the rest.

Try replacing the regeg with this:

^[a-z0-9][-\._a-z0-9]*@([a-z0-9][-_a-z0-9]*\.)+[a-z]{2,6}$

Note the opening ^ and closing $ : means that it matches exactly that
string -- the ^ is "beginning of string" and the $ is "end of string".
Not only does that make the regex, it also means you can change all
this:

        reversedmail = reverse(trim(email));
        if (NOT refindnocase("[a-z0-9]", left(reversedmail,1))) {
                badmailvar = 1;
        } else if (NOT refindnocase("[a-z0-9]", left(email,1))) {
                badmailvar = 1;
        } else if (listlen(email, "@") GT 2) {
                badmailvar = 1;
        } else if (NOT refindnocase(regex, email)) {
                badmailvar = 1;
        }

To just this:

      if (NOT refindnocase(regex, email)) {
                badmailvar = 1;
        }

Because the regex does all the work and you don't need the rest of the
tests.

Tim.


-------------------------------------------------------
RAWNET LTD - Internet, New Media and ebusiness Gurus.
Visit our new website at http://www.rawnet.com for
more information about our company, or call us free
anytime on 0800 294 24 24.
-------------------------------------------------------
Tim Blair
Web Application Engineer, Rawnet Limited
Direct Phone : +44 (0) 1344 393 441
Switchboard : +44 (0) 1344 393 040
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to