How can I change this regex?
/^(?=.*\d)(?=.*[A-Za-z]).{6,}$/
At the moment it checks at least 1 number and at least one letter present.
开发者_开发技巧How can I make it at least one number and at least 1 upper case letter??
Thanks all.
The part that matches the letter is [A-Za-z]
. This is a character class, signified by the square brackets, meaning that it will match any single character specified inside the brackets. In this case, it will match any uppercase letter (A-Z
) or lowercase letter (a-z
). To make it match uppercase letters only, simply remove the lowercase part so it looks like this: [A-Z]
.
精彩评论