Auteur: Graycode Date: À: Pcre-dev Sujet: Re: [pcre-dev] Forward reference don't work when repeated twice or
more
On Mon, 21 Nov 2011, ND wrote:
> PCRE version 8.20 2011-10-21
> /(a)(?2){2}(.)/
> abcd
> No match
>
> It seems that the whole string 'abcd' must be matched.
There appears to be an ambiguous issue with PCRE's determination of
what-to-repeat. That's illustrated by testing with 'abcda' or even
'abcdzzzza' which manage to find 'abcd'. Also testing with 'abca'
manages to find 'abca'. The compile seems to require another 'a'
down the road.
When the pattern is more explicit then it's more likely to be
interpreted properly. Both of the following work as expected:
/(a)((?3){2})(.)/
/(a)((?3)){2}(.)/
The following also seems to work, perhaps because what-to-repeat is
more clearly understood by the current code.
/a(?1){2}(.)/
I have a feeling Philip will be able to identify a potential solution.
I appreciate your notification about the issue, I'm just trying to
augment your report by providing a few clues that might aid in
resolving it.