regex - Match any number (or negitive number) except '-0' -


i have followin regex match number between 1 , 4 didgets in length, - character if desired.

^[-]?\d{1,4}$ 

however, i'd exclude list of possible matches -0. i've tried following, seems break everything.

^[-]?(?!-0)\d{1,4}$ 

how can achieve goal?

just put excluding group before :

^(?!-0)-?\d{1,4}$ 

note don't have put minus sign between brackets.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -