I use this to test for digits
/^\d+$/
But I need to make sure that it's greater than zero, while still allowing 0000123123123 for instance.
You can write:
/^\d*[1-9]\d*$/
(zero or more digits, followed by a nonzero digit, followed by zero or more digits).
It is correct regex for positive digits.
/^[1-9]\d*$/g
The previous answer not correct for 0123.
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