DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15461>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15461

Word boundry (\b) not matching using org.apache.regexp.RE

           Summary: Word boundry (\b) not matching using
                    org.apache.regexp.RE
           Product: Regexp
           Version: unspecified
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The word boundry escape \b does not seem to be matching.  Using the Jakarta-
Regexp-1.2 Binary implementation fails.  Perl5 works correctly as a comparison.

Simplest Example:

   Regexp: \b(eek.)
   Match against: "week"

   Jakarta returns "true" for a match, while Perl returns "false".

Workaround:

   Instead of \b I've been using (^|\s), but this changes my parenCount for 
retriving data.

Sample JSP:

<%@page import="org.apache.regexp.*"%>
<%
        String[] stringList = new String[] { "eekeek", "week", "my eeker", "the 
meeker" };

        String regExp = "\\b(eek.*)";
        RE testRE = new RE(regExp);

        out.write("<PRE>Testing RE Engine for word boundry: (" + regExp + ")
\n");
        for (int pos = 0; pos < stringList.length; pos ++)
        {
                if (testRE.match(stringList[pos]))
                {
                        int start = testRE.getParenStart(1);
                        int end = testRE.getParenLength(1) + start;
        
                        out.write("Matched " + stringList[pos].substring(0, 
start) + "<B><U>" + stringList[pos].substring(start, end) + "</U></B>" + 
stringList[pos].substring(end) + "\n");
                } else {
                        out.write("No Match: " + stringList[pos] + "\n");
                }
        }
%>

Result:

Testing RE Engine for word boundry: (\b(eek.*))
Matched eekeek
Matched week
Matched my eeker
Matched the meeker

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

Reply via email to