开发者

Regular Expression for recognizing non-negative values 1..99

开发者 https://www.devze.com 2023-01-25 03:30 出处:网络
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:

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]$/
0

精彩评论

暂无评论...
验证码 换一张
取 消