我需要帮助,以便在C#,asp.net中为以下内容创建正则表达式
这是我尝试过的:
Regex regex = new Regex(@"^(?=.{4,}$)(([\w\W])\2?(?!\2))+$");
Match matchRepeatedChars = regex.Match(OtherDetails);
regex = new Regex(@"^(?=.*\d)(?=.*[a-zA-Z]).{4,}$");
Match matchAlphaNumeric = regex.Match(OtherDetails);
regex = new Regex(@"(?=.*?[!#$%&()*+,-.:;=?@\[\]\^_~{}|])");
Match matchSpecielSpecialChar = regex.Match(OtherDetails);
//check consecutive characters
bool passwordHasConsecutivechars = false;
byte[] _byte = System.Text.Encoding.ASCII.GetBytes(OtherDetails.ToLower());
for (int i = 0; i < _byte.Length - 2; i++)
{
if ((_byte[i] + 1 == _byte[i + 1] && _byte[i] + 2 == _byte[i + 2]) || (_byte[i] - 1 == _byte[i + 1] && _byte[i] - 2 == _byte[i + 2]))
{
passwordHasConsecutivechars = true;
break;
}
}