[pcre-dev] Capturing brackets inside a recursion.

Αρχική Σελίδα
Delete this message
Συντάκτης: Herczeg Zoltán
Ημερομηνία:  
Προς: pcre-dev
Αντικείμενο: [pcre-dev] Capturing brackets inside a recursion.
Hi,

I played with capturing brackets inside a recursion a found a difference between PERL (5.10.1) and PCRE. I thought I may ask PERL developers about it because the effect seems strange to me, but the first mail I found on their list archives is not exactly inviting: http://www.nntp.perl.org/group/perl.beginners/2011/10/msg118878.html Perhaps someone here knows the answer.

/(.)(\1|a(?2))/ matches to "bab" in PCRE but not in PERL ().
/\1|(.)(?R)\1/ matches "cbbbc"in PCRE but not in PERL.

It seems to me that PERL does not see the content of capturing brackets inside a recursion. The following test proves this:

/(.)((?(1)c|a)|a(?2))/ matches to "baa" in PERL but not in PCRE.

What do you think, is this a bug or intended behaviour in PERL?

Regards,
Zoltan