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


Groups > comp.lang.python > #73806

Re: Get named groups from a regular expression

From Peter Otten <__peter__@web.de>
Subject Re: Get named groups from a regular expression
Date 2014-07-01 21:00 +0200
Organization None
References <louj52$j56$1@ger.gmane.org> <louk4e$1mt$1@ger.gmane.org> <CAPTjJmrudfOR1j2iJ2N2da_mQYdTtNGOhM6aghX5w1vnoe+xQQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.11383.1404241273.18130.python-list@python.org> (permalink)

Show all headers | View raw


Chris Angelico 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.

Hmm, it was a joke.

For a limited number of nestings you should be able to cook something up; I 
think Python allows up to 100 groups, so there is an upper limit of nesting 
levels. You might need a regex implementation that allows more than 100 
groups to parse your regex-parsing regex though...

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Get named groups from a regular expression Peter Otten <__peter__@web.de> - 2014-07-01 21:00 +0200

csiph-web