Reputation: 10575
I'm looking for a regular expression which can accept any value from 1 to 99 and does not accept any negative values. So far, I have:
"regex":/^[A-Za-z0-9]{3}[0-9]{6,}$/,
Upvotes: 0
Views: 2363
Reputation: 28588
This should work:
[1-9][0-9]?
If you want the whole string to be just a number, you need the ^$ included:
^[1-9][0-9]?$
That depends whether this is the whole regexp, or you want it to be a part of the bigger regexp.
Upvotes: 12
Reputation: 753535
If you want 1..99, then you probably want to use:
/^[1-9]|[1-9][0-9]$/
Upvotes: 2