Hi,
consider the following test case (jakarta-regexp-1.3-dev from snapshot
2002-02-24):
--- cut ---
import org.apache.regexp.RE;
public class regtest
{
public static void main(String args[])
{
try
{
regtest re = new regtest();
re.execute();
} catch(Exception e)
{
e.printStackTrace();
}
}
public void execute()
throws Exception
{
String expr = "^[\\w\\d\\.\\-]+$";
String match ="abenteuer-friedhof.de";
System.out.println("expr: "+expr);
System.out.println("match: "+match);
RE r = new RE(expr);
boolean matched = r.match(match);
System.out.println("Matches: "+matched);
}
}
--- cut ---
Running it produces:
expr: ^[\w\d\.\-]+$
match: abenteuer-friedhof.de
Matches: false
Which is wrong. The character class contains letters, numbers, the dot
and the hyphen. At least it should.
Bug fix is attached.
Regards
Henning
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH [EMAIL PROTECTED]
Am Schwabachgrund 22 Fon.: 09131 / 50654-0 [EMAIL PROTECTED]
D-91054 Buckenhof Fax.: 09131 / 50654-20
Index: src/java/org/apache/regexp/RECompiler.java
===================================================================
RCS file: /cvs/jakarta/regexp/src/java/org/apache/regexp/RECompiler.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- src/java/org/apache/regexp/RECompiler.java 25 Feb 2002 11:01:42 -0000 1.1.1.1
+++ src/java/org/apache/regexp/RECompiler.java 25 Feb 2002 11:02:49 -0000 1.2
@@ -72,7 +72,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jonathan Locke</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Michael McCallum</a>
- * @version $Id: RECompiler.java,v 1.1.1.1 2002/02/25 11:01:42 henning Exp $
+ * @version $Id: RECompiler.java,v 1.2 2002/02/25 11:02:49 henning Exp $
*/
public class RECompiler
{
@@ -710,7 +710,7 @@
else
{
// If simple character and not start of range, include it
- if ((idx + 1) >= len || pattern.charAt(idx + 1) != '-')
+ if ((idx + 1) >= len || pattern.charAt(idx) != '-')
{
range.include(simpleChar, include);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>