Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73827 > unrolled thread

Re: Get named groups from a regular expression

Started byDevin Jeanpierre <jeanpierreda@gmail.com>
First post2014-07-02 01:11 -0700
Last post2014-07-02 01:11 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Get named groups from a regular expression Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-07-02 01:11 -0700

#73827 — Re: Get named groups from a regular expression

FromDevin Jeanpierre <jeanpierreda@gmail.com>
Date2014-07-02 01:11 -0700
SubjectRe: Get named groups from a regular expression
Message-ID<mailman.11401.1404288767.18130.python-list@python.org>
On Tue, Jul 1, 2014 at 8:58 AM, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__peter__@web.de> wrote:
>> Easy, just write a regular expression to parse regular expressions ;)
>
> Hmm, is that even possible? AIUI you can't make a regex that correctly
> parses nested tokens, and named groups can definitely be nested.

Nesting isn't inherently a problem. Since nesting doesn't change the
way they parse, you can ignore nesting for the purposes of pulling out
named groups. Find each unescaped "(?P<...>".

(Making sure they are unescaped is annoying, though.)

-- Devin

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web