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.
Comments
Post a Comment