中國移動 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]3\d{8}$";
“^1(3[4-9]|4[7]|5[012789]|8[2378])\\d{8}$"
"^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"
"^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"
第一個是匹配手機號碼的
第二個是匹配手機號碼
第三個是匹配電子郵箱的。
手機前三個數字。
^1是文章的開頭為1 ,3 匹配3 ,4-9匹配4-9 組合是134,135,136,137,138,139
|是或者147 或者150,151,152,157,158,159,或者182,183,187,188開頭
\\\d{8}$'
\\d是數字。{8}為8位數字。$結束。
第二個和第一個類似,看懂第一個第二個也沒啥好說的。
第三個是@符號前面a-z0-9A-Z,是大小寫的字母加數字+是1-多個字符。-杠或者,\\.是匹配一個點
比如llds213. 或者sa24s-
@符號后面基本類似前面
不知道你能否明白?我是手敲的。正則工作后很有用,多看幫助文檔。
/** * 判斷該手機號碼是否是移動手機號段<br> * * @param phone * @return true or false * @throws Exception */ private boolean isMobileNumber(String phone) throws ServiceException { boolean isExist = false; phone = phone.trim(); if (phone == null || phone.length() < 7) { try { throw new Exception("wrong phone length"); } catch (Exception ex) { ex.printStackTrace(); } } String code = phone.substring(0, 7);// 暫時保留2009-01-16 16:30 if (code.startsWith("134") || code.startsWith("135") || code.startsWith("136") || code.startsWith("137") || code.startsWith("138") || code.startsWith("139") || code.startsWith("159") || code.startsWith("158") || code.startsWith("150") || code.startsWith("157") || code.startsWith("151") || code.startsWith("188") || code.startsWith("189")) { isExist = true; } return isExist; }