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

I have this regex but numbers but it allows -0, Any solution?

anubhava
  • 761,203
  • 64
  • 569
  • 643

1 Answers1

5

You may use a negative lookahead assertion to disallow certain match:

^(?!-0$)-?[0-9][0-9]{0,2}$

RegEx Demo

Take note of (?!-0$) that says fail the match if we have -0 and end anchor after matching start anchor ^.

anubhava
  • 761,203
  • 64
  • 569
  • 643