You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by T....@CEYONIQ.COM on 2001/10/31 10:01:11 UTC

Wrong Regexp or Bug in implementation of negated character classe s?

Hi Folks,    
 
I'm using the following code in a JUnit Test Suite. The Regexp
"^[^a-zA-Z0-9?&]?" is used to matche a couple of strings.
In assertEquals(....) I check, if the result of seperatorRegEx is false. As
far as I know either a "b", a "&" or a "?" 
should match my regex. 

Code:

    RE seperatorRegEx = new RE( new
RECompiler().compile("^[^a-zA-Z0-9?&]?"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match(","));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("."));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match(";"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("-"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("*"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("'"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("#"));
    assertTrue("seperatorRegEx fails", seperatorRegEx.match("~"));
    assertEquals("seperatorRegEx fails on garbage", false,
seperatorRegEx.match("b"));  <-- throws AssertionException (from JUnit)
    assertEquals("seperatorRegEx fails on garbage", false,
seperatorRegEx.match("&"));  <-- throws AssertionException (from JUnit)
    assertEquals("seperatorRegEx fails on garbage", false,
seperatorRegEx.match("?"));  <-- throws AssertionException (from JUnit)

I checked my regexp against a simple perl programm and the online-applet
form Apache-ORO package. 
So what's wrong with my regexp?

Any ideas?

Thx

Toby



Mit freundlichen Grüßen	
Best regards

Tobias Rademacher

----------------------------------------------------------------------------
------
Tobias Rademacher				 	 
Software Development
CEYONIQ Healthcare		Fon: +49 (0)821 44490-0
GmbH & Co. KG		    	Fax: +49 (0)821 44490-60 
Kurzes Geländ 6		    	mailto:t.rademacher@ceyoniq.com
86156 Augsburg		    	www.ceyoniq.com
Germany			   
----------------------------------------------------------------------------
-----------



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>