Google Groups Home
Help | Sign in
it IS A BUG!!!! find is not the same as match!!!!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
deanhiller  
View profile
 More options Jul 13, 9:14 pm
From: deanhiller <dean.hil...@gmail.com>
Date: Sun, 13 Jul 2008 18:14:28 -0700 (PDT)
Local: Sun, Jul 13 2008 9:14 pm
Subject: it IS A BUG!!!! find is not the same as match!!!!
In the documentation it has the following code which is NOT how they
do it in URLRewriter.  They use find not match and this just about
killed me.  Here is code proving find and match are different....

                String pat = "^/([a-zA-Z]*)(\\?.*)?";
                Pattern pattern1 =  Pattern.compile(pat, Pattern.CASE_INSENSITIVE);

                String url = "/web/home.xhtml";
                Matcher matcher = pattern1.matcher(url);

                boolean matches = matcher.matches();

                matcher.reset();

                //if not found return..
                boolean wasFound = matcher.find();

notice match returns false as I expect, and find returns true!!!!!

The documentation in URLRewriter has this which is not how they do it
in the code(they use find which IS different...this is a major BUG in
my eyes).....I was not expecting it to match my rule but it did
because it found a match inside my rule.  I should be able to define a
rule that if not matched continues on even if there is a section that
does match!!!  but I can't because URLRewriter was using fine...at
least in the version of code I have!!!

    Pattern.compile(<from> element);
    pattern.matcher(each request url);
    matcher.replaceAll(<to> element);
    if ( <condition> elements match && pattern matched ) {
    execute <run> elements (if any)
    perform <to> element (if any)
    }

Anyways, bottom line....Use find in your unit tests to determine if
your regex is correct..do not use match which is different!!!  Can we
get this fixed???


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Tuckey  
View profile
 More options Jul 13, 9:42 pm
From: "Paul Tuckey" <p...@tuckey.org>
Date: Mon, 14 Jul 2008 13:42:44 +1200
Local: Sun, Jul 13 2008 9:42 pm
Subject: Re: it IS A BUG!!!! find is not the same as match!!!!
This is the way it is supposed to work.  The psuedo code you are
looking at in the documentation is just that.  It is not java code.

Note, javadoc for find:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Matcher.html#...()

If you want your expression to be matches exactly begin it with a $
and end it with a ^.  This will force the entire string top be
matched.

eg, String pat = "^/([a-zA-Z]*)(\\?.*)?$";

Cheers,
Paul.

--
Cheers,
Paul.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google