1

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?

pit_ns
  • 75
  • 1
  • 8
  • ^(?=\d*[1-9])\d+$ Gleamed from: [stack overflow question](http://stackoverflow.com/questions/7036324/what-is-the-regex-for-any-positive-integer-excluding-0) – Bethany Seeger Oct 15 '14 at 15:29

1 Answers1

3
^(?!0$)\d+$

Try this.See demo.

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

vks
  • 67,027
  • 10
  • 91
  • 124