You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by vi...@gmxpro.net on 2003/02/23 23:25:53 UTC

group(i) returning null for nested group

Hi,

I have a problem with the following pattern:

        Pattern pattern = p5compiler.compile("(A)(B)((C)(D))+");
        Perl5Matcher p5matcher = new Perl5Matcher();
        p5matcher.setMultiline(true);
        if ( p5matcher.contains("ABCDE", pattern) ) {
            MatchResult result = p5matcher.getMatch();
            for ( int i = 0; i < result.groups(); i++) {
            System.out.println("" + i + ": " + result.group(i));
            }
        }

The output will be 

    0: ABCD
    1: A
    2: B
    3: 
    4: null
    5: D

Why is the 4th line: "4: null" and not "4: C" as I would have expected?

Regards
Victor


---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org