I would like to check if there is any occurrence of an uppercase or lowercase string in this:
test strings
1a
2A
3aC
js
const str = '1a'
/[a-z]/.test(str) //Pass
/[a-z][A-Z]/.test(str) //Fail
/[a-z]/.test(str) //Pass
I would like to check if there is any occurrence of an uppercase or lowercase string in this:
1a
2A
3aC
const str = '1a'
/[a-z]/.test(str) //Pass
/[a-z][A-Z]/.test(str) //Fail
/[a-z]/.test(str) //Pass
[a-z]
means 1 lowercase letter. [A-Z]
means 1 uppercase letter. [a-z][A-Z]
means 1 lowercase letter followed by 1 uppercase letter. [a-zA-Z]
means 1 lowercase or uppercase letter.
To check for "3aC" you might want [0-9][a-zA-Z]+
. The "+ means one or more lowercase or uppercase letters.