I have the following regex that I'm trying to ONLY allow numbers like:
1, 2, 3, 10, 11, 24 etc
and NOT 0, 01, etc
if (!$(this).text().match(/^[1-9][0-9]/g)) {
}
Is this correct? As it doesn't allow numbers like 1, 2, 3 but is 11, 12 etc
You need to specify a * after second [0-9] to match zero or more digits. In addition to one digit numbers, this will also fail to match more than two digit numbers. Correct regular expression is ^[1-9][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