Judging by this tick in Python up to version 3.5, there is a limit of 100 groups ( capturing groups ).
https://bugs.python.org/file36654/re_maxgroups.patch :
-``(?P=name)`` - A backreference to a named group; it matches whatever text was matched by the - earlier group named *name*. +``(?P=name)``, ``(?P=number)`` + A backreference to a group; it matches whatever text was matched by the + earlier group named *name* or numbered *number*. + + .. versionchanged:: 3.5 + Added support of group numbers. ``(?#...)`` A comment; the contents of the parentheses are simply ignored. diff -r 8a2755f6ae96 Lib/sre_compile.py --- a/Lib/sre_compile.py Thu Sep 18 19:45:04 2014 +0300 +++ b/Lib/sre_compile.py Thu Sep 18 23:27:28 2014 +0300 @@ -470,12 +470,6 @@ def compile(p, flags=0): # print code - # XXX: <fl> get rid of this limitation! - if p.pattern.groups > 100: - raise AssertionError( - "sorry, but this version only supports 100 named groups" - ) - # map in either direction groupindex = p.pattern.groupdict indexgroup = [None] * p.pattern.groups
I would still advise you to open a new question and describe your task with examples of input and "output" text / data - perhaps there is a more elegant solution ...