Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
ious, No problem, I can see why my question is weird. I actually implemented the interface above before I realized that these ambiguities even existed. On 08/04/2015, Denis McMahon wrote: > On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: > >> Example: re.compile(&#x

Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
#x27; matches the empty string and its span is identical to 'outer', then I need to know whether it is nested, or if it's outside like 'separate'. > Pardon me for stating the obvious, No problem, I can see why my question is weird. I actually implemented the interface

Get nesting of regex groups

2015-04-08 Thread Mattias Ugelvik
Example: re.compile('(?P(?Pa))') How can I detect that 'inner' is a nested group of 'outer'? I know that 'inner' comes later, because I can use the `regex.groupindex` (thanks to your help earlier: https://mail.python.org/pipermail/python-list/2015-April/701594.html). After looking a bit around, I

Re: Get the numbering of named regex groups

2015-04-08 Thread Mattias Ugelvik
Thank god it's that easy! Err, I mean, thank you! I should have read the docs more carefully :) On 08/04/2015, Peter Otten <__pete...@web.de> wrote: > Mattias Ugelvik wrote: > >> Example: re.match('(?Pa?)(?Pb?)', '') >> >> How can I find

Get the numbering of named regex groups

2015-04-08 Thread Mattias Ugelvik
Example: re.match('(?Pa?)(?Pb?)', '') 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 se

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

2015-04-08 Thread Mattias Ugelvik
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 -- https://mail.python.org/mailman/listinfo/p