Reputation: 71
Hello can someone help me creating a regex for numeric range from 1 to 25, I wouldn't like 01 02 etc just 1 2 3 ....
Thanks
My failed attempt /^([1-2]{1,2}[0-9])$/
Upvotes: 1
Views: 202
Reputation: 667
This is the "simple to understand" way
/^([1-9]|1[0-9]|2[0-5])$/
Breakdown:-
|
: or operator[1-9]
: match 1 to 91[0-9]
: match 10 to 192[0-5]
: match 20 to 25Upvotes: 4