I am searching for a regular expression that matches any string that is:
I tried this one without success:
^[1-9][0-9]*{1,12}$
If numbers with leading zeros that are greater than zero are allowed, you can use ^(?!0+$)[0-9]{1,12}$
if the tool/language you use supports lookaheads. The lookahead is used to ensure that the number doesn't entirely consist of zeros.
^[1-9][0-9]{0,11}$
Start with a single digit between 1-9, then have 0 to 11 occurrences of a digit between 0-9
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