1

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])$/

FatRat
  • 71
  • 7
  • 2
    See also https://stackoverflow.com/questions/39138073 (not a dupe, since it allows for leading zeroes) – MCO Feb 15 '20 at 17:26

1 Answers1

4

This is the "simple to understand" way

/^([1-9]|1[0-9]|2[0-5])$/

Breakdown:-

  • |: or operator
  • [1-9]: match 1 to 9
  • 1[0-9]: match 10 to 19
  • 2[0-5]: match 20 to 25
xxMrPHDxx
  • 657
  • 5
  • 11