Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88666
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <uglemat@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.043 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'example:': 0.03; '(at': 0.04; 'algorithm': 0.04; 'string': 0.09; "'')": 0.09; 'brackets': 0.16; 'parentheses': 0.16; 'positional': 0.16; '(the': 0.22; 'example': 0.22; 'documented': 0.24; 'least': 0.26; 'involving': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'python2.7': 0.31; 'interface': 0.32; 'regular': 0.32; 'quite': 0.32; 'bugs': 0.33; 'subject:the': 0.34; "can't": 0.35; 'problem.': 0.35; 'tool': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'searching': 0.37; 'to:addr:python-list': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'dangerous': 0.60; 'expression': 0.60; 'solve': 0.60; 'most': 0.60; 'skip:n 10': 0.64; 'subject:Get': 0.68; 'square': 0.74; "'first'": 0.84; 'subject:groups': 0.84; 'crucial': 0.91 |
| 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=i3BEqsMU906ZaZK+LbrWJbP8z6M/cKvOvTGxH92uifI=; b=xlDpBXcQiokjGm8/Ma81rv6DODLd1lO79J+JFgPTN00jry+3sB760Vy5JZ2cl4MZto 0xarUMbPaMg2f9RT3O8s7/npqB40ZHCW6+OM+Pxw/lkL5k+OLFDcycXniN8lAInWb9G/ L+vOMG1tuxR1CBLKUZ9/PkLrS5ehKk4K/2wQpORv2xtLCvBWa/AHtn01K5jtqhPRLxR3 BVflh9nYD9j5GWVugW6NHrUiCYoiNvyRMogDW/NFpy1knHPN3tzzVmkv+QrnT4NII/9X klBqWmEBMD4g7M6eeMMyLH8jTZH88YA/nxMs1Lx8gijobyTOAhE7WGroZnf6Y0HIxWCv zGfg== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.107.7 with SMTP id gy7mr11903023igb.49.1428500895076; Wed, 08 Apr 2015 06:48:15 -0700 (PDT) |
| Date | Wed, 8 Apr 2015 15:48:15 +0200 |
| Subject | Get the numbering of named regex groups |
| From | Mattias Ugelvik <uglemat@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| 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.139.1428500897.12925.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1428500897 news.xs4all.nl 2958 [2001:888:2000:d::a6]:41422 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88666 |
Show key headers only | View raw
Example: re.match('(?P<first>a?)(?P<second>b?)', '')
How can I find out that the group 'first' correlates to the positional
regex group 1? I need to know this to resolve crucial ambiguities in a
string manipulation tool I'm making. Looking at spans, as the example
above illustrates, won't do the job.
I can't see a way to do this through the documented interface (at
least not in the `re` module?). An algorithm involving searching for
'(' in the regular expression strings requires dealing with
parentheses in square brackets somehow + non-capturing groups in order
not to create rare bugs (the most dangerous of bugs).
If it's possible to get access to a regex AST, then I'm willing to
work with that (if the structure is stable), as it's quite important
that I solve this problem. I might be willing to drop Python2.7
support.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Get the numbering of named regex groups Mattias Ugelvik <uglemat@gmail.com> - 2015-04-08 15:48 +0200
csiph-web