如何验证密码是否包含至少一个大写或小写字母?

Gop*_*opi -1 c# regex passwords

标准

  1. 密码长度> = 8且<= 15
  2. 一位数(0-9),一个字母(AZ或az),一个特殊字符(@#$*!)

我试过这个

((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,15})
Run Code Online (Sandbox Code Playgroud)

但这会检查一个小写和大写,但我需要一个.

dca*_*tro 13

俗话说:"我遇到了问题,所以我想使用正则表达式.现在我有两个问题".

一个好的方法没有错.

public bool IsPasswordValid(string password)
{
    return password.Length >= 8 &&
           password.Length <= 15 &&
           password.Any(char.IsDigit) &&
           password.Any(char.IsLetter) &&
           (password.Any(char.IsSymbol) || password.Any(char.IsPunctuation)) ;
}
Run Code Online (Sandbox Code Playgroud)