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


Groups > comp.lang.python > #88698

Re: How to find out which named regular expression group corresponds to which positional regex group

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'subject:group': 0.05; 'string': 0.09; "'')": 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'correlation.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'subject:which': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'tool': 0.35; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'making': 0.63; 'charset:windows-1252': 0.65; 'skip:r 30': 0.69; "'first'": 0.84; 'subject:find': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Serhiy Storchaka <storchaka@gmail.com>
Subject Re: How to find out which named regular expression group corresponds to which positional regex group
Date Thu, 09 Apr 2015 10:49:03 +0300
References <CAFPwPpT=Gxi-4xmhVz0wJh0eAMAhejjQaLZFmx2QZoTeukNSxg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 193.202.118.165
User-Agent Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
In-Reply-To <CAFPwPpT=Gxi-4xmhVz0wJh0eAMAhejjQaLZFmx2QZoTeukNSxg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20
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.159.1428565752.12925.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1428565752 news.xs4all.nl 2902 [2001:888:2000:d::a6]:46128
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88698

Show key headers only | View raw


On 08.04.15 16:23, Mattias Ugelvik wrote:
> I'm making a string manipulation tool in which I need to know this correlation.
>
> Take this example: re.match('(?P<first>a?)(?P<second>b?)', '')
>
> I need to know that 'first' is group #1, and 'second' is group #2. I
> need this to resolve certain ambiguities. I was hopin

 >>> re.compile('(?P<first>a?)(?P<second>b?)').groupindex
mappingproxy({'first': 1, 'second': 2})

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


Thread

Re: How to find out which named regular expression group corresponds to which positional regex group Serhiy Storchaka <storchaka@gmail.com> - 2015-04-09 10:49 +0300

csiph-web