[vox-tech] regex to detect a range of numbers

Dave Margolis vox-tech@lists.lugod.org
Tue, 11 May 2004 11:32:35 -0700 (PDT)


Hello,

A co-worker of mine needs a PERL style regular expression that can match
the numbers 500-1800 NON-inclusive.  This is for a web application
(WebCT), and if you want to validate a field in the built-in quiz module,
you can only use a PCRE.  This feature is generally used to allow students
to type in answers that are case-insenstive, or allow for slight
misspellings, but in this case we're trying to bend the regular expression
support to do a little math for us.

Anyway, I came up with the following:
(^[5-9][0-9]{2}|^[1][0-7][0-9]{2})

This seems to be working for 500-1799, but apparently we're supposed to
rule out 500 as well.

Any ideas?

Thanks for your time,
Dave M.