If you're using regular expressions for lexing anything moderately complex, e.g a wiki markup, you could easily find yourself needing 100+ groups, especially if you're generating the expressions from some kind of input grammar
No, using a completely undocumented class that heavily relies on further undocumented parts of the standard library that might be implementation details of the regex implementation is much better.
It'll stay but it's still undocumented and the code heavily relies on things that are undocumented as well. This makes understanding it unnecessarily difficult and forces you to comment your own code quite extensively.
On the other hand you can easily generate a regular expression by doing a little bit of trivial string manipulation everyone is going to understand.
So take the 'undocumented' code, copy it, paste it into a file, put the license comment at the top, and move on with your life. String munging regexes together is going to be slower and error prone.
Such expressions are likely to be generated. In fact, the Python issue refers to a lexer for javascript. Imagine your design is to have one capturing group for each different language keyword, and suddenly it doesn't seem so silly any longer. https://bugs.python.org/issue22437
27 comments
[ 3.2 ms ] story [ 65.3 ms ] threadhttps://github.com/python/cpython/blob/3.4/Lib/re.py#L346
On the other hand you can easily generate a regular expression by doing a little bit of trivial string manipulation everyone is going to understand.
Oh, I hate that kind of error message. Why couldn't it be something useful like