classification
Title: Recursive regular expressions
Type: enhancement Stage: resolved
Components: Regular Expressions Versions: Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, kamek, mrabarnett, niemeyer, pwaller, r.david.murray, rhettinger, timehorse
Priority: normal Keywords:

Created on 2003-02-27 14:00 by kamek, last changed 2013-02-24 02:52 by mrabarnett. This issue is now closed.

Messages (10)
msg53789 - (view) Author: Daniel (kamek) Date: 2003-02-27 14:00
It would be great if Python's regexps supported recursive 
regular expressions, just like PCRE. For that it'd need 
its formations (?R), (?<name>) and (?P>name).
msg53790 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-28 06:31
Logged In: YES 
user_id=80475

This might be a worthwhile addition to Py2.4.
msg74105 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2008-09-30 23:44
I'll have a look at this. No promises, though.
msg74687 - (view) Author: Jeffrey C. Jacobs (timehorse) Date: 2008-10-13 14:13
The PCRE has some interesting suggestions on how the grammar for a 
recursive regular expressions might work.  I am concerned about the use of 
(?P>name) to call a regexp subexpression as an atomic subroutine.  The (?
P>name) format has never before been supported by Python and the (?P...) 
notation is exclusive to python, so it is strange the PCRE assigning us a 
use for (?P>name) without the Python community actually agreeing to it.  
Other than that, though, I think this is a possible feature we could add 
in issue 2636 as item 35.
msg74689 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2008-10-13 15:35
Perl (?number) for calling numbered groups and (?&name) for named groups
 (Perl also supports (?P>name)). (?R) is equivalent to (?0).

It's interesting that the documentation for both Perl and PCRE say that
they support (?P>name) because that's what Python uses!
msg84087 - (view) Author: Peter Waller (pwaller) Date: 2009-03-24 14:26
It looks like Matthew has dropped this feature from consideration.

See msg83993 .
msg84091 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2009-03-24 15:13
There are 2 reasons:

1. I've been told that my current patches contain too many differences
from the current implementation, so basically I have to go back to the
start and introduce any changes a little at a time, without knowing
whether any particular change will be accepted.

2. I think that recursive regular expressions are starting to stray into
the realm of pyparsing and so forth.

So I might not have the time (and I don't think I have the inclination!)
to implement them.
msg114221 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-18 14:02
Closing because of quote from msg83993 "Another feature request that I've decided not to consider any further is recursive regular expressions. There are other tools available for that kind of thing, and I don't want the re module to go the way of Perl 6's rules; such things belong elsewhere, IMHO."
msg182843 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-24 00:50
Agreed that this is unlikely to ever get implemented given that Matthew doesn't think it should be.
msg182848 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2013-02-24 02:52
FYI, I did eventually add it to my regex implementation. It was quite challenging!
History
Date User Action Args
2013-02-24 02:52:36mrabarnettsetmessages: + msg182848
2013-02-24 00:50:41r.david.murraysetstatus: open -> closed

assignee: niemeyer ->

nosy: + r.david.murray
messages: + msg182843
resolution: rejected
stage: resolved
2010-08-18 14:02:12BreamoreBoysetnosy: + BreamoreBoy
messages: + msg114221
2009-03-24 15:13:06mrabarnettsetmessages: + msg84091
2009-03-24 14:26:52pwallersetnosy: + pwaller
messages: + msg84087
2008-10-13 15:35:22mrabarnettsetmessages: + msg74689
2008-10-13 14:13:10timehorsesetmessages: + msg74687
2008-09-30 23:44:22mrabarnettsetnosy: + mrabarnett
messages: + msg74105
2008-09-28 19:34:07timehorsesetnosy: + timehorse
versions: + Python 2.7
2003-02-27 14:00:02kamekcreate