62,074
社区成员
发帖
与我相关
我的任务
分享
private static bool isCheckAll(string itemValue, string pass, string pass2, string email)
{
if (!IsRegEx(@"^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$", email))
{
return false;
}
else if (IsMailExist(email) != "success")
{
return false;
}
return true;
}
//正则表达式
private static bool IsRegEx(string regExValue, string itemValue)
{
try
{
Regex regex = new System.Text.RegularExpressions.Regex(regExValue);
if (regex.IsMatch(itemValue))
return true;
else
return false;
}
catch (Exception)
{
return false;
}
}
string str = "asdfsdwefdsadfccasdrdsasdffsssdd";
Regex rg = new Regex("cc|sss");
if (rg.IsMatch(str)) {
//"存在非法字符!"
}
//Regex rg = new Regex("cc|sss"); 意思是匹配的字符含有CC 或者 sss 就有非法字符
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator"
ControlToValidate="TextBox1" ValidationExpression="((?!xx|xy).)*"></asp:RegularExpressionValidator>