0

I want to determine if a string is any viable number, I have though made so many conditional statements it's not viable. The number can start with "-" (optional), if it has a leading 0 it can only contain a 0 (still "-" is optional).

Some examples:

123 = true

-123 = true

-0 = true

-00 = false

12+4 = false

I have used .matches but I can't seem to figure out how to put it in as few of conditions as possible.

PCheck
  • 25
  • 1
  • 6

0 Answers0