lp:~pythonregexp2.7/python/issue2636-04

Created by TimeHorse and last modified

In Perl 5.8, $-style back-references were augmented with the more industry-standard back-slash (reverse solidus) format and more recently in Perl 5.10, the using the \g group and \k keyword construct. As $-style is more or less very old-style Perl-specific, it shall not be implemented in Python. However, the \g-style construct, as well as the \k construct would not only provide a short-hand for keyword argument retrieval but the \g operator also allows for relative back-references. I.e. for an expression like r'(a)\g{-1}', the \g{-1} matches the last match group, which would be 'a' and therefor this expression matches the expression "aa". The main reason for adding the \g operator is to gain this relative back-reference functionality. The \g syntax would also allow for unnamed matches above 99 groups. Back-references could also be added to the standard \number pattern would interfere with the \{ or \- notation. Thus, the new back-reference formats to be added consist of:

\gn - Match group by absolute index n, n >= 1 (cannot be used recursively; n != 0)
\g{n} - Same as \gn to avoid expression ambiguity
\g{-n} - Match group by relative index n, n >= 1; -1 means last, -2 means penultimate read and so forth.
\g{name} - Shorthand for (?P=name)
\k<name> - Shorthand for (?P=name)
(?<name>...) - Shorthand for (?P<name>...)

The Python-specific names will remain in all cases; the Perl-specific extensions will be added in order to bring Python and Perl's regular Expression syntax more in line.

Get this branch:
bzr branch lp:~pythonregexp2.7/python/issue2636-04
Members of Python Regexp 2.7 can upload to this branch. Log in for directions.

Branch merges

Related bugs

Related blueprints

Branch information

Owner:
Python Regexp 2.7
Project:
Python
Status:
Development

Recent revisions

39029. By Jeffrey C. "The TimeHorse" Jacobs <email address hidden>

Merged in changes from the core Regexp branch.

39028. By Jeffrey C. "The TimeHorse" Jacobs <email address hidden>

Merged in changes from the core Regexp branch.

39027. By Jeffrey C. "The TimeHorse" Jacobs <email address hidden>

Merged in changes from the core Regexp branch.

39026. By Jeffrey C. "The TimeHorse" Jacobs <email address hidden>

Merged in changes from the core Regexp branch.

39025. By Jeffrey C. "The TimeHorse" Jacobs <email address hidden>

Merged in changes from the core Regexp branch.

39024. By Jeffrey C. Jacobs <email address hidden>

Merged in changes from Main Line

39023. By Jeffrey C. Jacobs <email address hidden>

Merged in changes from Main Branch

39022. By Jeffrey C. Jacobs <email address hidden>

Mainline merge

39021. By armin.rigo

A new crasher.

39020. By neal.norwitz

Fix typo (now -> no)

Branch metadata

Branch format:
Branch format 6
Repository format:
Bazaar pack repository format 1 with rich root (needs bzr 1.0)
This branch contains Public information 
Everyone can see this information.

Subscribers

No subscribers.