手机号正则表达式验证这样写是否正确(包括15开头新号段)

string s = @"^(13[0-9]|15[0|3|6|8|9])\d{8}$";

第1个回答  2013-06-23
我是在网站上抄的,应该对巴。

现在的手机号码增加了150,153,156,158,159
所以正则表达式如下: string s = @"^(13[0-9]|15[0|3|6|8|9])\d{8}$";

验证代码:

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = @"^(13[0-9]|15[0|3|6|8|9])\d{8}$";
while (true)
{
string input = Console.ReadLine();
if (Regex.IsMatch(input, s))
{
MessageBox.Show("完全符合!");
}
else
{
MessageBox.Show("不符合!");
}
}
}
}
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网