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


Groups > comp.lang.python > #88688

Re: Get nesting of regex groups

Date 2015-04-09 08:00 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: Get nesting of regex groups
References <mg46l7$2sr$5@dont-email.me>
Newsgroups comp.lang.python
Message-ID <mailman.152.1428530445.12925.python-list@python.org> (permalink)

Show all headers | View raw


On 08Apr2015 21:30, Denis McMahon <denismfmcmahon@gmail.com> wrote:
>On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote:
>
>> Example: re.compile('(?P<outer>(?P<inner>a))')
>>
>> How can I detect that 'inner' is a nested group of 'outer'? I know that
>> 'inner' comes later, because I can use the `regex.groupindex` (thanks to
>> your help earlier:
>> https://mail.python.org/pipermail/python-list/2015-April/701594.html).
>
>Pardon me for stating the obvious, but as the person defining the re, and
>assuming you haven't generated another sub-pattern somewhere in the same
>re with the same name, how can inner ever not be a nested group of outer?

If he has to ask this question, one might presume that he is not the source of 
the regexp. Ergo, he may not know the regexp structure ahead of time for 
whatever reason. I could invent scenarios for that, but perhaps Mattias can 
describe his situation some more.

Cheers,
Cameron Simpson <cs@zip.com.au>

In article <CF3rw3.n0x@eskimo.com> pirih@eskimo.com (Chris Pirih) writes:
| Wotsa zerk?

It's a portable hemispherical perforated spooge flange.
        - Chuck Rogers, car377@torreys.att.com

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


Thread

Get nesting of regex groups Mattias Ugelvik <uglemat@gmail.com> - 2015-04-08 22:54 +0200
  Re: Get nesting of regex groups Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-08 21:30 +0000
    Re: Get nesting of regex groups Cameron Simpson <cs@zip.com.au> - 2015-04-09 08:00 +1000
    Re: Get nesting of regex groups Mattias Ugelvik <uglemat@gmail.com> - 2015-04-08 23:58 +0200
    Re: Get nesting of regex groups Mattias Ugelvik <uglemat@gmail.com> - 2015-04-09 00:15 +0200

csiph-web