判断手机号归属运营商

 1     /**
 2      * 手机号归属运营商查询
 3      * @param phone
 4      */
 5     public static String mobileOperator(String phone) {
 6         // cmcc-中国移动手机号码规则
 7         String cmccRegex = "^[1]{1}(([3]{1}[4-9]{1})|([5]{1}[012789]{1})|([8]{1}[78]{1}))[0-9]{8}$";
 8         // cucc-中国联通手机号码规则
 9         String cuccRegex = "^[1]{1}(([3]{1}[0-2]{1})|([5]{1}[6]{1})|([8]{1}[56]{1}))[0-9]{8}$";
10         // cnc--中国电信手机号码规则
11         String cncRegex = "^[1]{1}(([3]{1}[3]{1})|([5]{1}[3]{1})|([8]{1}[09]{1}))[0-9]{8}$";
12         
13         if(phone.length()!=11){
14             return "手机号必须是11位";
15         }else if (phone.matches(cuccRegex)) {
16             return "中国联通的手机号码";
17         } else if (phone.matches(cmccRegex)) {
18             return "中国移动的手机号码";
19         } else if (phone.matches(cncRegex)) {
20             return "中国电信的手机号码";
21         } else {
22             return "未知的手机号";
23         }
24     }

 

posted on 2014-05-27 16:30  腾飞工作室  阅读(1418)  评论(0编辑  收藏  举报