Asp.Net中使用正则表达式进行数据验证

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

posted @ 2010-03-16 17:45  Jack Tang  阅读(245)  评论(0编辑  收藏  举报