I am trying to use the matches() function to check a user-entered password for certain conditions
“Contains six alphanumeric characters, at least one letter and one number”
Here is my current condition for checking for alphanumeric characters
pword.matches("([[a-zA-Z]&&0-9])*")
unfortunately in example using “rrrrZZ1” as the password this condition still returns false
What would be the correct regular expression? Thank you
Someone else here may prove me wrong, but this is going to be very difficult to do without an excessively complex regular expression. I’d just use a non-regular expression approach instead. Set 3 booleans for each of your conditions, loop through the characters and set each boolean as each condition is met, and if all 3 booleans don’t equal true, then fail the verification.
You could use something as simple as this: