Reputation: 23
i want a regex to allow 1-3 digits whole number,it should not start with 0 and should be a whole number,not decimals or fractions or any signed values,
this is what i have tried
"/^(\s*|\d{1,3})$/"
but it does not seem to work..
thanks in advance
Upvotes: 2
Views: 469
Reputation: 8839
^[1-9][0-9]\{,2\}$
It should be indeed end of line; end-of word will get the fractional part.
Upvotes: 0
Reputation: 726849
You can do it like this:
^(([1-9]\d?)|100)$
This would ensure that
Upvotes: 5