group(i) returning null for nested group
[email protected] Sun, 23 Feb 2003 23:25:53 +0100 (MET)
| Newsgroups | gmane.comp.jakarta.oro.user |
|---|---|
| Message-ID | <[email protected]> |
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