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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -