/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,8}/
This RegEx is supposed to validate a password, which should contain at least one digit, both lowercase and uppercase characters. Can anyone explain this RegEx by smaller components?
/(?=.\d)(?=.[a-z])(?=.*[A-Z]).{6,8}/
This regex is generally used to validate password, i.e.
password should contain 1 UpperCase,1 LowerCase and 1 numeric and no special characters.
(?=.*\d) //at least 1 numeric charater.
(?=.*[a-z]) //atleast 1 lowercase.
(?=.*[A-Z]) //atleast 1 uppercase.
.{6,8} //string is of 6 to 8 length.
Hope this helps.
(?=.*\d) ensures your string has a digit in it.
(?=.*[a-z])ensures your string has a lowercase ASCII letter in it.
(?=.*[A-Z])ensures your string has a uppercase ASCII letter in it.
.{6,8} matches a string of atleast 6 and atmost 8 characters.
Since the anchors are missing, your regex would match any string which has as its substring a string that satisfies all of the above 4 conditions.
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