Skip to content

Behavior of backreferences to named groups in regular expressions unclear #49132

Closed

Description

@aresnick
mannequin
BPO 4882
Nosy @birkenfeld
Files
  • re-backreference-clarification.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/birkenfeld'
    closed_at = <Date 2009-03-31.19:07:20.189>
    created_at = <Date 2009-01-08.15:35:46.076>
    labels = ['type-feature', 'docs']
    title = 'Behavior of backreferences to named groups in regular expressions unclear'
    updated_at = <Date 2009-03-31.19:07:20.188>
    user = 'https://bugs.python.org/aresnick'

    bugs.python.org fields:

    activity = <Date 2009-03-31.19:07:20.188>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2009-03-31.19:07:20.189>
    closer = 'georg.brandl'
    components = ['Documentation']
    creation = <Date 2009-01-08.15:35:46.076>
    creator = 'aresnick'
    dependencies = []
    files = ['13016']
    hgrepos = []
    issue_num = 4882
    keywords = ['patch']
    message_count = 5.0
    messages = ['79417', '79525', '80100', '81568', '84863']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'jimjjewett', 'aresnick']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4882'
    versions = ['Python 2.6']

    Activity

    1. aresnick commented on Jan 8, 2009

      aresnickmannequin
      MannequinAuthor

      I recently learned about named groups in Python regular expressions.
      Almost all the documentation I've found online explains what they are
      and give a simple example of how to use them. I was trying to use the
      variables outside of the original regex, later in the code. Nowhere in
      the documentation I found after a couple hours of searching was it
      mentioned that named groups can only be backreferenced _within_ the pattern.

      In particular, the sections at
      http://www.amk.ca/python/howto/regex/#SECTION000530000000000000000 and
      the description of the (?P<name>) behavior at
      http://docs.python.org/library/re.html could be modified to make it
      clear that the named capture does not create a variable usable outside
      of the pattern.

      I would be happy to alter the documentation appropriately.

    2. added
      docsDocumentation in the Doc dir
      type-featureA feature request or enhancement
      on Jan 8, 2009
    3. jimjjewett commented on Jan 10, 2009

      jimjjewettmannequin
      Mannequin

      That sounds like a good idea, particularly since it is a bit different
      from Perl. Please do write up the a clarification.

      Typically, I have either attached a file with the suggested wording, or
      included it in a comment from which a commiter could cut-and-paste.

      (If Georg has different preferences on how to submit the patch, they
      should probably go into a FAQ anyhow.)

    4. birkenfeld commented on Jan 18, 2009

      @birkenfeld
      Member

      I'm happy to review such a patch.

    5. aresnick commented on Feb 10, 2009

      aresnickmannequin
      MannequinAuthor

      Hi Georg!

      Sorry to be so long in getting back to you. I've attached a suggested
      patch for the python-2.6.1-docs-text/library/re.txt documentation.
      Also, in looking over Kuchling's HOWTO, the necessary information is
      actually there, and I just wasn't paying attention =) Let me know if
      I should do something else--this is my first 'fix'/submission to
      Python, and I'm eager for feedback.

      Thanks!

      Gratefully,
      a.

    6. birkenfeld commented on Mar 31, 2009

      @birkenfeld
      Member

      Committed a similar patch in r70866.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    docsDocumentation in the Doc dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions