Regex for numeric range from negative numbers?

There it´s It can or not start with the negative symbol, followed by a number between 1 and 9 ant then can be 0 to 2 of any number.

^\-?[1-9]\d{0,2}$

Update: And the following regex also allows decimals

^\-?[1-9]\d{0,2}(\.\d*)?$

Assuming you are dealing with whole integers, and your number don't mix with other texts, you can try this

^-?[1-9][0-9]{0,2}$

I agree with Anon, it is much better to read the String, and convert it to int to do the comparison, if you have predictable inputs.

Tags:

Regex