Reputation: 15
This should be so easy to do however I have been searching online and trying different patterns on http://gskinner.com/RegExr/ with no success!
I need to match all numbers and numbers only (from the beginning) except 1 or anything starting with a leading 0 so these would match
2
222
1234567
and these would not:
01
1
someword
Your help would be much appreciated! Thank you.
Upvotes: 1
Views: 71
Reputation: 18550
^((?:[2-9][0-9]*)|(?:1[0-9]+))$
would work, Spiting each case
Example http://regex101.com/r/wW9jQ7
Upvotes: 3
Reputation: 72855
Simplest way with no negation and no lookarounds:
^([2-9][0-9]*|[1-9][0-9]+)$
Working example: http://regex101.com/r/xZ2zC5
Upvotes: 0