Regular Expression for recognizing non-negative values 1..99
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 开发者_如何学Pythonhave:
"regex":/^[A-Za-z0-9]{3}[0-9]{6,}$/,
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.
If you want 1..99, then you probably want to use:
/^[1-9]|[1-9][0-9]$/
精彩评论