Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive patterns #27

Closed
mrabarnett opened this issue Dec 23, 2011 · 2 comments
Closed

Recursive patterns #27

mrabarnett opened this issue Dec 23, 2011 · 2 comments
Labels
enhancement New feature or request trivial

Comments

@mrabarnett
Copy link
Owner

Original report by Anonymous.


In order to parse certain strings belonging to certain kinds of languages, recursive patterns for recursive matching are necessary. For example, if you want to parse and capture a parenthesized chunk of text which may contain nested parenthesis, you'll need to have recursion.

Perl already supports recursive matching, so does PCRE and with that many libraries for languages such as PHP. I always wondered why the Python regex engines never did.

Please refer to http://perldoc.perl.org/perlre.html for documentation on the widely accepted syntax for recursive patterns.

@mrabarnett
Copy link
Owner Author

Original comment by Anonymous.


Please could you provide a set of tests, checking what the groups should match, including the expected results of the matched.captures() method. Try to make them short but thorough.

Note that Perl allows backtracking into the recursive part, whereas PCRE doesn't (it treats the recursive part as atomic).

I'm aiming for the Perl behaviour.

@mrabarnett
Copy link
Owner Author

Original comment by Anonymous.


Added in regex 0.1.20120103.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request trivial
Projects
None yet
Development

No branches or pull requests

1 participant