Your regexp is matching anything that has the literal string "0-9" in it. And then the !~ negates that match. Thus, since anything you've tried probably does not include the literal string "0-9" somewhere in it, the full expression is always true.
You want to match a character class - e.g., \d matches all digits, thus using /\d/ is a bit closer. What this does is match any digit, anywhere in the string.
You actually want to match 1 to 5 digits. So you can use the {} modifier: /\d{1,5}/. This matches anywhere from 1 to 5 digits, anywhere in the string. But that still matches "a1b" since it has somewhere between 1 and 5 digits. So you want to anchor the match to both the beginning and the end. And thus we get /^\d{1,5}$/.
Hope that helps. perlretut may help.
In reply to Re: Filtering CGI Input
by Tanktalus
in thread Filtering CGI Input
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |