Re: group(i) returning null for nested group

Anakreon Mejdi <[email protected]>
Newsgroups gmane.comp.jakarta.oro.devel
Message-ID <[email protected]>
[email protected] wrote:
> In message <[email protected]>, Anakreon Mejdi writes:
> 
>>I found the same problem too.
> 
> 
> 1. Don't send me personal emails.  Direct emails like this to
>    [email protected].
Sorry.
I am not subscribed to the list.
I Used the mail archive to check about the
problem

> 2. This problem was fixed a while ago.  Use the latest CVS checkout.
> 
Version 2.0.7 did not work.
Because of firewall I can't use CVS.
However I downloaded via html CVS (I think this is how it is named)
the files which were at most 3 months old.
It still doesn't work properly.

Here  are some tests I did to verify if it is a bug:

Reg Exp:\s*(\d{1,2})\.(\d{1,2})(-(\d{1,2})\.(\d{1,2}))*(ΞΌΞΌ|πμ)
Input: 7.00-9.00-11.00ΞΌΞΌ

The output of matchResultExample is:
java -cp classes matchResultExample 
"\s*(\d{1,2})\.(\d{1,2})(-(\d{1,2})\.(\d{1,2}))*(ΞΌΞΌ|πμ)" " 
7.00-9.00-11.00ΞΌΞΌ"

Match:  7.00-9.00-11.00ΞΌΞΌ
Length: 18
Groups: 7
Begin offset: 0
End offset: 18
Groups:
1: 7
Begin: 1
End: 2
2: 00
Begin: 3
End: 5
3: -11.00
Begin: 10
End: 16
4: 11
Begin: 11
End: 13
5: 00
Begin: 14
End: 16
6: ΞΌΞΌ
Begin: 16
End: 18

The -9.00 is lost and -11.00 exists in three different groups.

If I tried input: 7.00-9.00-11.00-12.30ΞΌΞΌ
The result is:
Match:  7.00-9.00-11.00-12.30ΞΌΞΌ
Length: 24
Groups: 7
Begin offset: 0
End offset: 24
Groups:
1: 7
Begin: 1
End: 2
2: 00
Begin: 3
End: 5
3: -12.30
Begin: 16
End: 22
4: 12
Begin: 17
End: 19
5: 30
Begin: 20
End: 22
6: ΞΌΞΌ
Begin: 22
End: 24

All the matches except the last one are lost in the 3 group.

As a workaround I used this pattern:
\s*(\d{1,2})\.(\d{1,2})((-\d{1,2}\.\d{1,2})*)(ΞΌΞΌ|πμ)
group 3 will have in the above example string:-9.00-11.00-12.30
The String of the third group is sliced by an other regular expression.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.