I need help with a pattern to match a zero-padded integer which is not all zeros. It can have zero to n leading zeros. So far I have:
^[0-9]{0,}[1-9]{1}$"
but this does not get things like 000860
because of the last zero. I feel like this should be simple, but I can't get it. Any help would be much appreciated.
EDIT: A few people have asked which engine/language this is. I thought regex was standardized so it wouldn't matter. But it's .NET.
Why not using this:
^0*[1-9][0-9]*$
? Btw, you missed to specify the regex engine in use. But the above pattern should work in almost any regex engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With