[英]using ^[A-Za-z ][A-Za-z0-9!@#$%^&* ]*$ reg validation password how apply length in c# code behind
Using password regex validation: 使用密码正则表达式验证:
^[A-Za-z ][A-Za-z0-9!@#$%^&* ]*$
How I apply length into that in c# code behind server? 如何在服务器后面的C#代码中将长度应用于长度?
You can try like this: 您可以这样尝试:
^[A-Za-z ][A-Za-z0-9!@#$%^&* ]{8,15}*$
This {8,15} means that the length could be between 8 to 15 {8,15}表示长度可以在8到15之间
Well this might be what you are expecting 好吧,这可能就是您所期望的
public static bool IsValidPassword (string input)
{
Match match = Regex.Match(input, @"(?=^.{8,12}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*");
if (match.Success && match.Index == 0 && match.Length == input.Length)
return true;
else
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.