Hi Paul,

setPattern() is an undocumented method of an implementation class. From a
user perspective I wouldn't "expect" it to do anything. It's not part of
the API and no guarantee that it will even be there from release to release
(though probably unlikely that we'd remove it). The only place Xerces ever
calls setPattern() is within the constructor of RegularExpression. That's
probably the only place where it was intended that it would be called.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

gea...@ieee.org wrote on 02/19/2009 04:13:24 PM:

> Hi,
>
> I've been having some (apparently) odd behavior with regular
> expressions. Can anyone please tell me if the following program should
> work as I am seeing?
> ---
> import org.apache.xerces.impl.xpath.regex.RegularExpression;;
>
> public class ReTest {
>   public static void main(String[] args) {
>     String s = "Another test";
>     String p1 = "foo";
>     String p2 = "foo.*test";
>
>     RegularExpression re = new RegularExpression(p1);
>     print(s, p1, re.matches(s));
>     re.setPattern(p2);
>     print(s, p2, re.matches(s));
>     re = new RegularExpression(p2);
>     print(s, p2, re.matches(s));
>   }
>
>   static void print(String str, String pattern, boolean match) {
>     System.out.print("Pattern '" + pattern);
>     if (match) System.out.print("' matches '");
>     else System.out.print("' does not match '");
>     System.out.println(str + "'");
>   }
> }
> ---
>
> The output I expect to see is:
>   Pattern 'foo' does not match 'Another test'
>   Pattern 'foo.*test' does not match 'Another test'
>   Pattern 'foo.*test' does not match 'Another test'
>
> The output I actually see is:
>   Pattern 'foo' does not match 'Another test'
>   Pattern 'foo.*test' matches 'Another test'
>   Pattern 'foo.*test' does not match 'Another test'
>
> In other words, setPattern() is not working the way I expect it to. Is
> this right?
>
> Thanks in advance,
> Paul Gearon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org

Reply via email to