alert(/[a-z]+/.test("4Nyth1n&_."));
why the output is true? doesn't it supposed to match just the alphabet from a to z (lower case)?
test
just looks for a match of a substring. In this case, the substring yth
matches. If you want to match the whole string, insert ^
and $
:
alert(/^[a-z]+$/.test("4Nyth1n&_."));
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