Sure you could; the more important question is should you. You're probably better off implementing a "lower level" check (is this a 4 digit number) at the regex level and then using comparisons in code to check range membership.
What you want to be worried about is when your requirements shift and now you've got to check if it's between 3021 and 5123 for the comparisons-in-code version it's just a matter of changing two numbers (or redefining FOO_RANGE_MIN and FOO_RANGE_MAX constants since one would never use magic numbers inline, of course :) rather than coming up with a new clever regex to match the new rage.
Update: Just to show it can be done (but again, probably shouldn't): /^ 3 (?: 0 [1-9] \d | [1-9] \d \d ) | 4 (?: 0 \d \d | 1 (?: [01] \d | 2 [0123] ) ) $/x
In reply to Re^2: Regular expression for hexadecimal number
by Fletch
in thread Regular expression for hexadecimal number
by isha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |