Are Python regular expressions PCRE compatible

snafu wrote:Hm, parse nested structures is exactly what I'm interested in at the moment. And if you can transfer the PHP examples, that would be really great.

I can't promise you that, I concentrated on the Perl code and I don't know whether the Perl REs from the examples can be transferred to PCRE. PCRE doesn't always have what it says on it ("Perl Compatible ...").


IIRC he creates (in many ways) a recursive pattern in which he repeats RE sections depending on recursion conditions

However, in theory PHP and Python should be compatible.


The PHP part says at least:
-----------------------------------------
475 Recursive Expressions
475 Matching Text with Nested Parentheses
476 Recursive reference to a set of capturing parentheses
476 Recursive reference via named capture
477 More on possessive quantifiers


Just have a look at the bookstore ... I did too!

The code examples can also be downloaded from O'Reilly.

(UPDATE: at least you could do that earlier)

BTW: real regular expressions wouldn't allow recursions.

UPDATE:
1) yup should help "(? R)" has become standard in both PCRE and Perl.
see also "RECURSIVE PATTERNS" at http://www.pcre.org/pcre.txt.
perldoc perlre also contains examples for the use of "(? PARNO)" (PARNO is the number of the preceding grouping bracket)