^-?[0-9][0-9]{0,2}$
I have this regex but numbers but it allows -0
, Any solution?
^-?[0-9][0-9]{0,2}$
I have this regex but numbers but it allows -0
, Any solution?
You may use a negative lookahead assertion to disallow certain match:
^(?!-0$)-?[0-9][0-9]{0,2}$
Take note of (?!-0$)
that says fail the match if we have -0
and end anchor after matching start anchor ^
.