This is an example for regular expression which allow both decimals as well as integers with a range limit of 40-180
Regex Pattern:

/^([4-8][0-9]|[4-8][0-9]\d{0,9}(\.\d{1,3})|9[0-9]\d{0,9}(\.\d{1,3})|1[0-7][0-9]|1[0-7][0-9]\d{0,9}(\.\d{1,3})|180)$/

  • [4-8][0-9] : Parse Into Range 40 – 89
  • [4-8][0-9]\d{0,9}(\.\d{1,3}) : Parse Into Range 40.00 – 89.00
  • 9[0-9] : Parse Into Range- 90 – 99
  • 9[0-9]\d{0,9}(\.\d{1,3}) : Parse Into Range- 90.00 – 99.00 with three decimal places
  • 1[0-7][0-9] : Parse Into Range- 100 – 179
  • 1[0-7][0-9]\d{0,9}(\.\d{1,3} : Parse Into Range- 90.00 – 99.00 with three decimal places
  • 180 : Parse Into Range – 180-180