Get named groups from a regular expression
jeanpierreda at gmail.com
Wed Jul 2 10:11:57 CEST 2014
On Tue, Jul 1, 2014 at 8:58 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__peter__ at web.de> wrote:
>> Easy, just write a regular expression to parse regular expressions ;)
> Hmm, is that even possible? AIUI you can't make a regex that correctly
> parses nested tokens, and named groups can definitely be nested.
Nesting isn't inherently a problem. Since nesting doesn't change the
way they parse, you can ignore nesting for the purposes of pulling out
named groups. Find each unescaped "(?P<...>".
(Making sure they are unescaped is annoying, though.)
More information about the Python-list