本文共 510 字,大约阅读时间需要 1 分钟。
//手机号码特点:1+(3,4,5,6,7,8)+(9位数字)//正则表达式//^1[3-8]\d{9}$if(number.matches("^1[3-8]\\d{9}$")){//匹配手机号码 //匹配之后要进行的操作}else if(number.matches("^\\d+$")){//匹配数字 switch (number.length()) { case 3: address = "报警电话"; break; case 4: address = "模拟器"; break; case 5: address = "客服电话"; break; case 7: case 8: address = "本地号码"; break; default: // 01088881234 // 048388888888 if (number.startsWith("0") && number.length() > 10) {// 有可能是长途电话 // 有些区号是4位,有此项区号是3位(包括0) //先查询4位区号 //没找到就再查询3位区号 } break; }}
转载地址:http://sphpf.baihongyu.com/