Asp.Net中使用正则表达式进行数据验证
using System.Text.RegularExpressions;
private bool checkMobile(string mobile)
{
string regex0 = @"\d{11}";
string regex = @"(13[0-9]?|15[89])[0-9]{8}";
if (!Regex.IsMatch(mobile, regex0) || !Regex.IsMatch(mobile, regex))
{
return false;
}
return true;
}
详细内容可参考 "ASP.NET 中的正则表达式"
文章地址:http://msdn.microsoft.com/zh-cn/library/ms972966.aspx