pit_ns
pit_ns

Reputation: 75

PHP - cannot find correct regex

I am trying to figure out a regex that would match 012 but wound't match 0. So basically if the string is one character and that character equals 0 then it should false but it should work with values like 012, 023, 01, 05, 120.

I tried that but it doesn't do what i want.

^(?=[^0])(?=[0-9]{1,3})$

Any idea?

Upvotes: 1

Views: 29

Answers (1)

vks
vks

Reputation: 67968

^(?!0$)\d+$

Try this.See demo.

http://regex101.com/r/dZ1vT6/27

Upvotes: 3

Related Questions