Certainly even 1 million chars would not be a limit in a Perl regex. There is really no absolute limit, only performance issues.

Update: ok, in some systems the max limit will be limited by 16 bit positive integer.

Let's not get de-focused here, what is it that you are trying to do? .{250,1000} looks like a strange thing to do.

Your regex says at least 250 chars AND something less than or equal to 1,000 chars on that line. Meaning that 249 chars won't match. 1001 chars on the line won't match. 651 characters will match. What is the point and the application?

#!/usr/bin.perl -w use strict; my $test = "1234"; my @digits = ($test =~ m/^(.{4,5})$/); print "digits = @digits\n"; #prints digits = 1234 $test = "12345"; @digits = ($test =~ m/^(.{4,5})$/); print "digits = @digits\n"; #prints digits = 12345 $test = "123456"; @digits = ($test =~ m/^(.{4,5})$/); print "digits = @digits\n"; #prints digits =
There is another thread running about the difference been "nothing" and "undef" for an @var. There is a difference and the above shows it. The issue in that thread is Why? Not that this it is true. In this last example, @digits is "nothing", not undefined, same as @digits=();

The above will print..

digits = 1234 digits = 12345 digits =

In reply to Re: Regex question by Marshall
in thread Regex question by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.