正则表达式
string Mobile = @"^1((3[0-9]|4[57]|5[0-35-9]|7[0678]|8[0-9])\d{8}$)";//手机
string Telephone = @"^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$";//电话
string MT = @"((^1((3[0-9]|4[57]|5[0-35-9]|7[0678]|8[0-9])\d{8}$))|(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$))";//手机+电话
string CM = @"^1(3[4-9]|4[7]|5[0-27-9]|7[08]|8[2-478])\\d{8}$";//移动
string CU = @"^1(3[0-2]|4[5]|5[256]|7[016]|8[56])\\d{8}$";//联通
string CT = @"^1(3[34]|53|7[07]|8[019])\\d{8}$";//电信
string EM = @"([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+";//邮箱
引入
using System.Text.RegularExpressions;
代码
Regex reg = new Regex(MT);
if (!reg.IsMatch(phone))
{
context.Response.Write("{\"status\":0,\"msg\":\"请填写正确的联系电话!\"}");
return;
}
Copyright © 2004-2024 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4