6 ms·
Some might say if you need 100+ regex groups you have other problems...
by orf 11y ago
Some might say if you need 100+ regex groups you have other problems...
- lilbobbytables 11y agoI've got 99 problems, but >100 regex tables isn't one.
- deleted 11y ago[deleted]
- harryf 11y agoIf 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
- justin_vanw 11y agoIf you are lexing there is a much better way than trying to munge together a giant regex manually: https://github.com/python/cpython/blob/3.4/Lib/re.py#L346 https://github.com/python/cpython/blob/3.4/Lib/re.py#L346
- DasIch 11y agoNo, 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.
- justin_vanw 11y agoIt's been there for like 10 years, I think you'll be ok if you use it... If it goes away, you can just bring it back right?
- DasIch 11y agoIt'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.
- justin_vanw 11y agoSo 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.
- Mithaldu 11y agoOr you are using regexes generated programmatically.
- dogma1138 11y agohttps://xkcd.com/1171/ https://xkcd.com/1171/