As the title reads, we can easily match nested parentheses in regex with e.g.
(\(((?:[^()]+|(?1))+))
which will match balanced parentheses.
How can we use a named subgroup instead, as e.g. in
(?P<key>\(((?:[^()]+|(?\g<key>))+))
I'm not looking for a parser solution or anything but really for the pattern above in Python (regex module) or PCRE.
(?&key)....re. theregexpackage on PyPI is a third-party package with the most prominent feature being that it can fuzzy match.