Regular Expression for a range >= 0 but less than 1000

In light of your recent changes to the question, here is an updated regex which will match all >= 0 and <1000

^\d{1,3}(?:\.\d{1,5})?$
  ^\___/ \/ ^\/\___/ |
  |  ^   ^  | |  |   `- Previous is optional (group of dot and minimum 1 number between 0-9 and optionally 4 extra numbers between 0-9)
  |  |   |  | |  `- Match 1-5 instances of previous (single number 0-9)
  |  |   |  | `- Match a single number 0-9
  |  |   |  `- The dot between the 1-3 first number(s) and the 1-5 last number(s).
  |  |   `- This round bracket should not create a backreference
  |  `- Match 1-3 instances of previous (single number 0-9)
  `- Match a single number 0-9

^ is start of line, $ is end of line.

Valid

  • 999.99999
  • 999.0
  • 999
  • 99.9
  • 99.0
  • 99
  • 9
  • 0.1
  • 0.01
  • 0.001
  • 0.0001
  • 0.99999
  • 0.01234
  • 0.00123
  • 0.00012
  • 0.00001
  • 0.0
  • 0.00000
  • 0
  • 000.00000
  • 000

Invalid

  • -0.1
  • 999.123456
  • AAA
  • AAA.99999
  • 0.
  • .123

Tags:

Regex