I found this regex online but I am struggling to understand it. It is this:
(?=^.{6,10}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{":;'?/>.<,])(?!.*\s).*$
http://regexlib.com/Search.aspx?k=password&c=-1&m=5&ps=100
The description is:
This regular expression match can be used for validating strong password. It expects at least 1 small-case letter, 1 Capital letter, 1 digit, 1 special character and the length should be between 6-10 characters. The sequence of the characters is not important. This expression follows the above 4 norms specified by Microsoft for a strong password.
I see there are the following groups. I have read that ?=
means look ahead.
(?=^.{6,10}$)
Does this means looks ahead that there should be 6-10 characters?(?=.*\d)
Does this mean that look ahead that there should be 0 or more characters followed by a digit (so at least one digit)?. Could this have been written as(?=\d+)
meaning there should be at least 1 digit?(?=.*[a-z])
pattern to matcha-z
. Again, could this have been written as(?=[a-z]+)
?(?=.*[A-Z])
pattern to matchA-Z
. Again, could this have been written as(?=[A-Z]+)
?(?=.*[!@#$%^&*()_+}{":;'?/>.<,])
Is.*
not required here as well?(?!.*\s).*$
- what does this mean?