Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'subject:group': 0.05; 'string': 0.09; "'')": 0.09; 'subject:How': 0.10; 'correlation.': 0.16; 'subject: \n ': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'subject:which': 0.16; 'certain': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'tool': 0.35; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'making': 0.63; "'first'": 0.84; 'subject:find': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=lkG1IQKbVTHXEnzBQCo2HS0xopGucDjs7HkVUEWvsGM=; b=oCT8MuiaUnmqwEvAHdJYyNeEK/iv5oa6VcuCMoUDTh0DHkIqDoL3APIaNvOhljYnq5 4Cac/hxE1WeaYSfkMv3fewPKG4oSjQDqXPPgOFJz6BS8bIwLpYMCPFcJ8ED94/X+p9Fc +Qn9XVGq93+msSUfEeula0Bzx4DLa9lv4jEbjBZPKMeybGV6BvGvexvUqs1Seo6KerZy DoJQ9X+6cUcgulRmq+ovmbs8zsP2cKD9j6T4XmUO1dG2DH5qGCZ61c3Wp3YZzpr1xxQD ZIUH8KL/cnTz3Y54POL8VB1sSQorE2Jo6MDl2c4IvyqQrvDnhPjy81M13BTxQe6Vdi9T ztnQ== MIME-Version: 1.0 X-Received: by 10.50.138.68 with SMTP id qo4mr11639968igb.33.1428499399882; Wed, 08 Apr 2015 06:23:19 -0700 (PDT) Date: Wed, 8 Apr 2015 15:23:19 +0200 Subject: How to find out which named regular expression group corresponds to which positional regex group From: Mattias Ugelvik To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-Mailman-Approved-At: Wed, 08 Apr 2015 15:24:48 +0200 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: 6 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428499489 news.xs4all.nl 2835 [2001:888:2000:d::a6]:56085 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88663 I'm making a string manipulation tool in which I need to know this correlation. Take this example: re.match('(?Pa?)(?Pb?)', '') I need to know that 'first' is group #1, and 'second' is group #2. I need this to resolve certain ambiguities. I was hopin