5 ms·
Python 3.4 supports only 100 regex groups
- namtrac 11y agoI guess you meant Python 3.4 because 3.5 has no limitation: https://github.com/python/cpython/blob/3.5/Lib/sre_compile.py https://github.com/python/cpython/blob/3.5/Lib/sre_compile.p...
- jepler 11y agoyeah it took me a bit to figure it out but "lt" in the original post text is supposed to mean "less than" or "older than"..
- raldi 11y agoI thought it said "Python it"
- TazeTSchnitzel 11y agoHacker News strips < and > from titles, which is probably why they used "lt" instead.
- MosheZada 11y agoYes you are right, sorry for the confusion
- orf 11y agoSome 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?
- 11y ago
- 0x0 11y agohttps://github.com/python/cpython/commit/33455fe85760e0173eeecef52c76de4240e10663#diff-5812393a306237111d8f76f73783e386 https://github.com/python/cpython/commit/33455fe85760e0173ee...
- joshmaker 11y ago> raise error("groups number is too large") Oh, I hate that kind of error message. Why couldn't it be something useful like raise error("groups number is too large " "(you have used %d out of an " "allowed %d)" % (self.groups, MAXGROUPS))
- brianwawok 11y agoIt has a todo. Possibly just s fast hack till you can come back and fix it... Then fast hack became release :)
- deleted 11y ago[deleted]
- agumonkey 11y agoI'd like to see someone type a regex with 100 capturing groups.
- rgacote 11y agoI'd like to see someone _debug_ a regex with 100 capturing groups.
- jepler 11y agoSuch 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 https://bugs.python.org/issue22437
- lucb1e 11y agoCpython, right? Not python the language,if I understand this correctly.
- rnhmjoj 11y agoYeah, like GHC supporting only up to 62-tuple. Very limiting.