in reply to Range of numbers

No. [0-9] sets a set of characters, not numbers.

Do what you want with a regex is possible but, AFAIK cumbersome: /^(2[5-9]\d|[3-6]\d\d|7[0-2]\d|730)$/ should work (not tested)

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

Replies are listed 'Best First'.
Re^2: Range of numbers
by JavaFan (Canon) on Oct 10, 2008 at 20:01 UTC
    I wouldn't mix ranges with numbers and \d in a regexp, unless you know your perl is older than 5.6.

    Since the previous millennium, Perl has supported Unicode in some way or another. Which means that while [0-9] matches 10 characters, \d matches many more. Several hundreds of different characters in 5.10. Your suggested pattern,

    /^(2[5-9]\d|[3-6]\d\d|7[0-2]\d|730)$/
    matches 333, 33۳ and 3۳3, but not ۳33 (۳ is Arabic 3).

      ++ Thank you for the answer. I never thought that Unicode can be an issue in recognizing numbers.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."