What’s the regular expression for positive whole numbers only? (zero is not allowed)
I was able to get the regular expression for numbers only which is ^\d+$. I’ve been trying to look for one online but it’s already been an hour so I’ve decided to post it here on Stack Overflow.
matches:
1 || 2 || 444 || 9000 || 012
non-matches:
9.2 || -90
May be you are looking for
^[1-9]+$pattern. It’ll match1245,2253etc. But not1003. or0124. If you want to match the 3rd number (1003) as well use^[1-9]\d*$pattern.In php you’d use