最新手机号码正则表达式

看了MYM.Brooks的提示,修改一下表达式,添加了最新的号码。

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

万雅虎  的提示,添加180,147等,更加全面的表达式:

^(1(([35][0-9])|(47)|[8][0126789]))\d{8}$

 

再次修改添加了183,并添加了座机的,如下:

手机:^(1(([35][0-9])|(47)|[8][01236789]))\d{8}$

座机:^0\d{2,3}(\-)?\d{7,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}$";

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

posted @ 2008-07-16 10:14  acles  阅读(30117)  评论(18编辑  收藏  举报