Reputation: 163
I've tried several options without success.
(105)|(0*\d{1,2})
This is where I go?
Upvotes: 2
Views: 394
Reputation: 34377
I like the answer above /10[0-5]|[0-9]{1,2}/
but it is not anchored so it will match things like 990 and 1051. It will match as a regexp I mean.
To anchor the regexp use ^ at the start and $ at the end. Here's an improved version of the answer
/^(10[0-5]|\d{1,2})$/
I've used \d
which is a commonly available shortcut for [0-9] digits
Edit: see tripleee's comment below, also needs ( ) to group the two alternate expressions
Upvotes: 3
Reputation: 10619
This could be the better one:
\b0*(10[0-5]|[0-9]{1,2})\b
Takes care of leading Zeros.
Upvotes: 0
Reputation: 4408
You can always use a match evaluator and check for any condition you want.
Upvotes: 0
Reputation: 6757
How about this:
/10[0-5]|[0-9]{1,2}/
Upvotes: 3