I'm trying to create a RegExpression to meet the criteria below;
So far I got this;
^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.\s).*$
However I can not get it to work. Any help would be greatly appreciated. I was never good at puzzles :)
a minimum of 1 special character: ~`! @#$%^&*()-_+={}[]|\;:"<>,./? at least 1 upper case, numeric, and special character must be EMBEDDED somewhere in the middle of the password, and not just be the first or the last character of the password string.
You're nearly there; it's just the .*
at the end that ignores your "no spaces/special characters" rules, and the (?=.\s)
lookahead is wrong (you probably meant (?!.*\s)
or (?=\S*$)
).
But you don't need that lookahead anyway because you can simply specify which characters are allowed (and enforce the "8 characters minimum" rule there, too):
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$
But why do you want to keep users from using non-alphanumeric characters in their passwords?
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