Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88663 > unrolled thread
| Started by | Mattias Ugelvik <uglemat@gmail.com> |
|---|---|
| First post | 2015-04-08 15:23 +0200 |
| Last post | 2015-04-08 15:32 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
How to find out which named regular expression group corresponds to which positional regex group Mattias Ugelvik <uglemat@gmail.com> - 2015-04-08 15:23 +0200
Re: How to find out which named regular expression group corresponds to which positional regex group Damien Wyart <damien.wyart@free.fr> - 2015-04-08 15:32 +0200
| From | Mattias Ugelvik <uglemat@gmail.com> |
|---|---|
| Date | 2015-04-08 15:23 +0200 |
| Subject | How to find out which named regular expression group corresponds to which positional regex group |
| Message-ID | <mailman.138.1428499489.12925.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Damien Wyart <damien.wyart@free.fr> |
|---|---|
| Date | 2015-04-08 15:32 +0200 |
| Message-ID | <55252dfc$0$2988$426a34cc@news.free.fr> |
| In reply to | #88663 |
* Mattias Ugelvik <uglemat@gmail.com> in comp.lang.python:
> 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.
Building a mapping between the results of groups and groupdict on the
match object should be quite straightforward.
--
DW
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web