Jim,

Apparently the workaround I suggested the other day wasn't the best one, as
it allowed you to compile but then failed at match-time.

This new fix seems to work OK in both java.util.regex and org.apache.regexp:

^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][\-\w]*[0-9a-zA-Z]\.)+[a-zA-Z
]{2,9})$

My guess is that [-\w] and [\w-] are either not well defined or mishandled
by regexp; in either case escaping the hyphen takes care of (or avoids) the
problem.

Interestingly regexp did accept [-.\w] ...

 Reuben


-----Original Message-----
From: Jim K [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 12, 2006 6:12 PM
To: regexp-user@jakarta.apache.org
Subject: Re: Bad character class exception on pattern that works for JDK's
Pattern class

I ran through a bunch of unit tests to validate that the RE compiled pattern
operated the same as when compiled with either ORO's Perl5Compiler or Java's
Pattern.  I found that in one instance it did not:

[EMAIL PROTECTED]@host.com

I'd expect this pattern to fail the match and it does for ORO and Java.  But
it
passes when run through Apache regexp.  The pattern as amended is:

^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][\w-]*[0-9a-zA-Z]\.)+[a-zA-Z]
{2,9})$





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

Reply via email to