more than 100 capturing groups in a regex

Iain King iainking at gmail.com
Tue Oct 25 09:30:35 EDT 2005


Steven D'Aprano wrote:
> On Tue, 25 Oct 2005 05:17:52 -0700, Iain King wrote:
>
> >
> > Fredrik Lundh wrote:
> >> Joerg Schuster wrote:
> >>
> >> > I just want to use more than 100 capturing groups.
> >>
> >> define "more" (101, 200, 1000, 100000, ... ?)
> >>
> >> </F>
> >
> > The Zero-One-Infinity Rule:
> >
> > http://www.catb.org/~esr/jargon/html/Z/Zero-One-Infinity-Rule.html
>
>
> Nice in principle, not always practical. Sometimes the choice is, "do you
> want it today with arbitrary limits, or six months from now with bugs
> but no limits?"
>
> If assigning arbitrary limits prevents worse problems, well, then go for
> the limit. For instance, anyone who has fought browser pops ups ("close
> one window, and ten more open") may have wished that the browser
> implemented an arbitrary limit of, say, ten pop ups. Or even zero :-)
>

Well, exactly.  Why limit to ten?  The user is either going to want to
see pop-ups, or not.  So either limit to 0, or to infinity (and indeed,
this is what most browsers do).
Note the jargon entry defines infinity in this case to me the largest
possible amount given whatever ram/disk space/processing power you have
available.

Also: These arbitrary limits tend to stem from languages which
predominantly use fixed size arrays - DIM in basic, or malloc in C.
The native python component is the list, which doesn't have a max size,
so these problems should be encountered less in python code; by it's
nature, python steers you away from this mistake.

Iain




More information about the Python-list mailing list