in reply to Is there a hard limit on + in a regex?

You said that the real regex is more complex. Does it include an explicit quantifier?

+ seems happy to match 160,000 repetitions on either 5.6.1 or 5.8.4, but it doesn't like explicit quantifier greater than 32766.

P:\test>perl5.6.1 -Mstrict -wle "my $s= '<object>' x 160_000; print 'Ok' if $s =~ m[^(?:<object>)+$]" Ok P:\test>perl5.8.4 -Mstrict -wle "my $s= '<object>' x 160_000; print 'Ok' if $s =~ m[^(?:<object>)+$]" Ok P:\test>perl5.8.4 -Mstrict -wle "my $s= '<object>' x 160_000; print 'Ok' if $s =~ m[^(?:<object>){1600 +00}$]" Quantifier in {,} bigger than 32766 in regex; marked by <-- HERE in m/^(?:<object>){ <-- HERE 160000}$/ at -e line 1 +.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: Is there a hard limit on + in a regex?
by diotalevi (Canon) on Jul 09, 2004 at 19:46 UTC

    Your first two examples set the quantifier as {1,REG_INFTY} because they were simple enough to allow it (exact matches, no capturing, etc). You cannot explicitly name quantifiers higher than REG_INFTY and now I quote some comments from the source.

    The default size for REG_INFTY is I16_MAX, which is the same as SHORT_MAX (see perl.h). Unfortunately I16 isn't necessarily 16 bits (see handy.h). On the Cray C90, sizeof(short)==4 and hence I16_MAX is ((1<<31)-1), while on the Cray T90, sizeof(short)==8 and I16_MAX is ((1<<63)-1). To limit stack growth to reasonable sizes, supply a smaller default. --Andy Dougherty 11 June 1998

    Perhaps you can change this default locally?

      Dunno. I grepped for I16_MAX and found it is set to INT16_MAX. So I grepped for that, and couldn't find where that is defined?

      Anyhow, it appears that what I am seeing on Win32 is of little interest.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
Re^2: Is there a hard limit on + in a regex?
by samtregar (Abbot) on Jul 09, 2004 at 19:59 UTC
    No, it doesn't.

    -sam