[pcre-dev] Backtracking atomic blocks

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

the current backtracking behaviour of PCRE for atomic blocks is not exactly logical to me, so I tried to compare it with PERL (v5.12.1). I don't know PERL (yet), this is actually my first PERL script:

my $str = "aaaabaaabaabab";
@myarray = ($str =~ m/((?>(a+)b)+aabab)/);
print join(",", @myarray), "\n";

Its result is: aaaabaaabaabab,aaa

I don't know how to extract the starting/ending positions, that is why I choose this tricky example, since I can see that the result of the internal capturing bracket is the second block. Even I don' understand why the array does not contain the full match...

With PCRE, the result is the following: 0, 14, 0, 14, 12, 13 - the internal capturing bracket holds the last 'a'. Am I interpret right that this is a different behaviour?

Regards,
Zoltan