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


Groups > comp.lang.python > #73827

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!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'expressions': 0.07; 'nested': 0.07; 'cc:addr:python-list': 0.11; 'nesting': 0.16; 'parse,': 0.16; 'possible?': 0.16; 'pulling': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'unescaped': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'parse': 0.24; 'cc:2**0': 0.24; 'purposes': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'easy,': 0.31; 'regular': 0.32; 'subject:from': 0.34; "can't": 0.35; 'problem.': 0.35; 'received:google.com': 0.35; 'sure': 0.39; 'even': 0.60; 'expression': 0.60; 'to:addr:gmail.com': 0.65; 'subject:Get': 0.68; 'groups.': 0.74; 'jul': 0.74; 'otten': 0.84; 'subject:groups': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=c7szvOhwAE3hr/jpFqlhHYXkKi8gbFoxDl11S6IYA/A=; b=stt9ffGoYx7Cu0eo2IVCUlkZSN+DNpVWwFkqB4wDKoArQIz29GWQLJSylxOajRh/R5 v3pnyzJBFMGWumKEX/zUgEgCC14QLp97k7XeoCV1RxMxjmG6BAvVOq1TD8E4gNyrojXP ybmoTlsufIexEzNg636oyHhQzN9IAsuG5qjiHUvLgOWQ+bKasUOoRAJnXet5NzBPWY6Q fOZNOx4x7ywPu+Juus+DgUsOAF7y9jiWcAxVpbK7UikomyDqDviRUtwZbZUQeAPa1aBA AWJ0ZC9AOsEONRATlLcNbB8ed8oaDoAEhBWnCKOp9iO2Cy0nJluKtoP50cUn6D8gtb+O zADQ==
X-Received by 10.140.92.167 with SMTP id b36mr7469071qge.97.1404288758044; Wed, 02 Jul 2014 01:12:38 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAPTjJmrudfOR1j2iJ2N2da_mQYdTtNGOhM6aghX5w1vnoe+xQQ@mail.gmail.com>
References <louj52$j56$1@ger.gmane.org> <louk4e$1mt$1@ger.gmane.org> <CAPTjJmrudfOR1j2iJ2N2da_mQYdTtNGOhM6aghX5w1vnoe+xQQ@mail.gmail.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Wed, 2 Jul 2014 01:11:57 -0700
Subject Re: Get named groups from a regular expression
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc "python-list@python.org" <python-list@python.org>
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.11401.1404288767.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404288767 news.xs4all.nl 2976 [2001:888:2000:d::a6]:41356
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73827

Show key headers only | View raw


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

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


Thread

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

csiph-web