标签:style blog http java color javascript
1 /** 2 * 手机号归属运营商查询 3 * @param phone 4 */ 5 public static void mobileOperator(String phone) { 6 // cmcc-中国移动手机号码规则 7 String cmccRegex = "^[1]{1}(([3]{1}[4-9]{1})|([5]{1}[89]{1}))[0-9]{8}$"; 8 // cucc-中国联通手机号码规则 9 String cuccRegex = "^[1]{1}(([3]{1}[0-3]{1})|([5]{1}[3]{1}))[0-9]{8}$"; 10 // cnc--中国网通3G手机号码规则 11 String cncRegex = "^[1]{1}[8]{1}[89]{1}[0-9]{8}$"; 12 13 if(phone.length()!=11){ 14 System.out.println("手机号必须是11位"); 15 }else if (phone.matches(cuccRegex)) { 16 System.out.println("中国联通的手机号码"); 17 } else if (phone.matches(cmccRegex)) { 18 System.out.println("中国移动的手机号码"); 19 } else if (phone.matches(cncRegex)) { 20 System.out.println("中国网通3G的手机号码"); 21 } else { 22 System.out.println("未知的手机号"); 23 } 24 }
标签:style blog http java color javascript
原文地址:http://www.cnblogs.com/tfgzs/p/3755376.html