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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'expressions': 0.07; 'nested': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'though...': 0.09; 'python': 0.11; 'nesting': 0.16; 'possible?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'header :User-Agent:1': 0.23; 'parse': 0.24; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'easy,': 0.31; 'allows': 0.31; 'regular': 0.32; 'subject:from': 0.34; "can't": 0.35; 'something': 0.35; 'there': 0.35; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'expression': 0.60; 'more': 0.64; 'subject:Get': 0.68; 'limit': 0.70; 'jul': 0.74; 'upper': 0.74; '100': 0.79; 'otten': 0.84; 'subject:groups': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Get named groups from a regular expression
Date Tue, 01 Jul 2014 21:00:53 +0200
Organization None
References <louj52$j56$1@ger.gmane.org> <louk4e$1mt$1@ger.gmane.org> <CAPTjJmrudfOR1j2iJ2N2da_mQYdTtNGOhM6aghX5w1vnoe+xQQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bdb5e7.dip0.t-ipconnect.de
User-Agent KNode/4.11.5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11383.1404241273.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404241273 news.xs4all.nl 2956 [2001:888:2000:d::a6]:51489
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73806

Show key headers only | 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