On Mon, Jul 14, 2008 at 1:14 PM, deanhiller <dean.hil
...@gmail.com> wrote:
> 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???
--