Admin.net框架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
908 B

5 days ago
namespace Admin.NET.Core;
/// <summary>
/// 正则校验
/// </summary>
public static class RegularValidate
{
/// <summary>
/// 验证密码规则
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static bool ValidatePassword(string password)
{
var regex = new Regex(@"
(?=.*[0-9]) #
(?=.*[a-z]) #
(?=.*[A-Z]) #
(?=([\x21-\x7e]+)[^a-zA-Z0-9]) #
.{8,30} #830
", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);
//如果要求必须包含小写、大写字母,则上面的(?=.*[a-zA-Z]) 要改为:
/*
* (?=.*[a-z])
* (?=.*[A-Z])
*/
return regex.IsMatch(password);
}
}