正则表达式验证⼿机号和座机号
资源来源于⽹络
联通现有号段是:130、131、132、155、156、186、185,其中3G专属号段是:186、185。还有⽆线上⽹卡专属号段:145。移动现有号段是:134、135、136、137、138、139、150、151、152、157、158、159、182、183、184、188、187、178。电信现有号段是:133、153、177、180、181、189、199。
#region正则表达式验证电话号码
public static bool CheckMobliePhoneV2(string phone)
{
//电信⼿机号码正则
string dianxin = @"^1[35789][01379]\d{8}$";
Regex dReg = new Regex(dianxin);
//联通⼿机号正则
string liantong = @"^1[34578][01256]\d{8}$";
Regex tReg = new Regex(liantong);
//移动⼿机号正则
string yidong = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$";
Regex yReg = new Regex(yidong);
if (dReg.IsMatch(phone) || tReg.IsMatch(phone) || yReg.IsMatch(phone))
{
return true;
}
正则匹配手机号码return false;
}
/
//<summary>
///座机号格式校验
///</summary>
///<param name="telephone"></param>
///<returns></returns>
public bool checkTelephone(string telephone)
{
string zuoji = @"^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$"; //⽐如:028-028********或0312-4295xxx的格式
Regex gex = new Regex(zuoji);
if (gex.IsMatch(telephone))
{
return true;
}
return false;
}
#endregion
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论