Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
(sorry if I'm spamming the mailing list, my reply didn't seem to show up in the archive) I'm making a 'declarative string manipulation' tool, the interface of which should work like this: >>> rules(r'(?P(?Pa?))(?Pb?)', { ... 'separate': '.suffix', ... 'inner': 'abc', ... 'outer': lambda str

Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
I'm making a 'declarative string manipulation' tool, the interface of which should work like this: >>> rules(r'(?P(?Pa?))(?Pb?)', { ... 'separate': '.suffix', ... 'inner': 'abc', ... 'outer': lambda string: 'some-{}-manipulation'.format(string) ... }).apply('a') 'some-abc-manipulation.suffix

Re: Get nesting of regex groups

2015-04-08 Thread Cameron Simpson
On 08Apr2015 21:30, Denis McMahon wrote: On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: 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 earli

Re: Get nesting of regex groups

2015-04-08 Thread Denis McMahon
On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: > 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/piper

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