I am working on a requirement wherein I have to create a strong password. The following condition has to be met:
-> It should be a combination of Cap Letter, Small Letter, Number and Special character
Can I write a regex expression for this? If yes how ?
For example, to validate a password of at least 8 characters:
if (Regex.IsMatch(subjectString,
@"^ # Start of string
(?=.*\p{Lu}) # Assert at least one uppercase letter
(?=.*\p{Ll}) # Assert at least one lowercase letter
(?=.*\d) # Assert at least one digit
(?=.*[^\p{L}\d]) # Assert at least one other character
.{8,} # Match at least 8 characters
$ # End of string",
RegexOptions.IgnorePatternWhitespace))
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