regex - Regular expression for 1-199 (including both 1 and 199) without Leading zeros -


regular expression match number 1 199. leading zeros not included, means f.ex. 015 not allowed.

first, know may better convert integer or something, can check range. right paly ragular expresison.

second, first attemp.

^[1]?[1-9][0-9]?$ 

but seems miss match of "10x" 101, 102 make one:

^([1]\d{2} | [1-9][0-9]?)$ 

no sure works. if not, what's wrong, otherwise, there elegant way(more generic) write it, can address problem 1 ~ 1999 ect.

you can use regex:

^([1-9][0-9]?|1[0-9]{2})$ 

regex demo


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -