jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 2121] New: - '.' or '-' in bracket expression gives unexpected results
Date Mon, 11 Jun 2001 19:26:15 GMT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2121

*** shadow/2121	Mon Jun 11 12:26:15 2001
--- shadow/2121.tmp.1948	Mon Jun 11 12:26:15 2001
***************
*** 0 ****
--- 1,71 ----
+ +============================================================================+
+ | '.' or '-' in bracket expression gives unexpected results                  |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 2121                        Product: Regexp                  |
+ |       Status: NEW                         Version: unspecified             |
+ |   Resolution:                            Platform: Other                   |
+ |     Severity: Normal                   OS/Version: Windows NT/2K           |
+ |     Priority: Other                     Component: Other                   |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: regexp-dev@jakarta.apache.org                                |
+ |  Reported By: edwin@bitstorm.nl                                            |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ This problem has been discussed on the regexp mailinglist
+ (June 8, 2001, Subject "Regexp broken").
+ 
+ I made an JSP page in which I test some RE's.
+ 
+ I have a string "{regexp-1.2}" and I want an RE which
+ matches everything between the brackets (thus "regexp-1.2").
+ 
+ Let's try some regular expressions:
+ 
+ Input string "{regexp-1.2}" and RE "([a-z0-9]+)" match: "regexp"
+ Input string "{regexp-1.2}" and RE "([a-z0-9-]+)" match: "{regexp-1.2}"
+ Input string "{regexp-1.2}" and RE "([a-z0-9.]+)" match: "regexp"
+ Input string "{regexp-1.2}" and RE "([a-z0-9.-]+)" match: "{regexp"
+ Input string "{regexp-1.2}" and RE "([a-z0-9\-]+)" match: "regexp-1"
+ Input string "{regexp-1.2}" and RE "([a-z0-9\.]+)" match: "regexp"
+ Input string "{regexp-1.2}" and RE "([a-z0-9\.\-]+)" match: "regexp-1"
+ Input string "{regexp-1.2}" and RE "([a-z0-9.\-]+)" match: "regexp-1"
+ Input string "{regexp-1.2}" and RE "([a-z0-9\.-]+)" match: "{regexp"
+ 
+ Some strange results and none of them gives "regexp-1.2"!
+ 
+ This is the JSP-code, so you can try it yourself:
+ 
+ <%@ page import="org.apache.regexp.*" %>
+ 
+ <%!
+ JspWriter JspOut;
+ 
+ public void reTest( String in, String re ) throws java.io.IOException, 
+ org.apache.regexp.RESyntaxException {
+         JspOut.print( "Input string \""+in+"\" and RE \""+re+"\" match: ");
+         RE testRe = new RE(re);
+         if ( testRe.match( in ) )
+                 JspOut.print( "\""+testRe.getParen(1)+"\"" );
+         else
+                 JspOut.print( "no match" );
+         JspOut.print("<br>");
+ }
+ %>
+ 
+ <%
+ JspOut = out;
+ String s = "{regexp-1.2}";
+ 
+ reTest( s, "([a-z0-9]+)" );
+ reTest( s, "([a-z0-9-]+)" );
+ reTest( s, "([a-z0-9.]+)" );
+ reTest( s, "([a-z0-9.-]+)" );
+ reTest( s, "([a-z0-9\\-]+)" );
+ reTest( s, "([a-z0-9\\.]+)" );
+ reTest( s, "([a-z0-9\\.\\-]+)" );
+ reTest( s, "([a-z0-9.\\-]+)" );
+ reTest( s, "([a-z0-9\\.-]+)" );
+ %>
\ No newline at end of file

Mime
View raw message