最简单的验证电话号码与手机号码做法
验证电话号码:在regularexPRessionvalidator属性中的validationexpression中添加d{3,4}-d{7,8}
手机号码:^[1]d{10}
这种是不严格的,只要是11位数字就是手机,或3-4打头中间-后根7-8数字就是电话,下面我们可以分析出
中国移动 134.135.136.137.138.139.150.151.152.157.158.159.187.188 ,147(数据卡) 
中国联 通130.131.132.155.156.185.186 
中国电信133.153.180.189 
CDMA 133,153
	  
		| 代码如下 | 复制代码 | 
	  
		| ///
 /// 匹配移动手机号
 ///
 public const string PATTERN_CMCMOBILENUM = @"^1(3[4-9]|5[012789]|8[78])d{8}$";
 ///
 /// 匹配电信手机号
 ///
 public const string PATTERN_CTCMOBILENUM = @"^18[09]d{8}$";
 ///
 /// 匹配联通手机号
 ///
 public const string PATTERN_CUTMOBILENUM = @"^1(3[0-2]|5[56]|8[56])d{8}$";
 ///
 /// 匹配CDMA手机号
 ///
 public const string PATTERN_CDMAMOBILENUM = @"^1[35]3d{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("不符合!");
 }
 }
 }
 }
 }
 |