Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'url:pipermail': 0.05; 'detect': 0.07; 'nested': 0.07; 'skip:` 10': 0.07; 'stating': 0.09; '>on': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'portable': 0.16; 'presume': 0.16; 'reason.': 0.16; 'rogers,': 0.16; 'simpson': 0.16; 'url:html)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'header:User- Agent:1': 0.23; 'cheers,': 0.24; "haven't": 0.24; 'source': 0.25; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'writes:': 0.31; 'another': 0.32; 'url:python': 0.33; 'could': 0.34; 'but': 0.35; '+0200,': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'ahead': 0.38; 'question,': 0.38; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'that,': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'content-disposition:inline': 0.62; 'situation': 0.65; 'subject:Get': 0.68; 'article': 0.77; '2015': 0.84; 'chuck': 0.84; 'received:192.168.15': 0.84; 'regexp': 0.84; 'subject:groups': 0.84; 'obvious,': 0.91 Date: Thu, 9 Apr 2015 08:00:33 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: Get nesting of regex groups MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) References: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428530445 news.xs4all.nl 2964 [2001:888:2000:d::a6]:59286 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88688 On 08Apr2015 21:30, Denis McMahon wrote: >On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: > >> Example: re.compile('(?P(?Pa))') >> >> 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 In article pirih@eskimo.com (Chris Pirih) writes: | Wotsa zerk? It's a portable hemispherical perforated spooge flange. - Chuck Rogers, car377@torreys.att.com