|
|
|
@ -5,10 +5,11 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
mobile = "mobile" // 中国移动
|
|
|
|
|
unicom = "unicom" // 中国联通
|
|
|
|
|
telecom = "telecom" // 中国电信
|
|
|
|
|
virtual = "virtual" // 虚拟
|
|
|
|
|
Mobile = "mobile" // 中国移动
|
|
|
|
|
Unicom = "unicom" // 中国联通
|
|
|
|
|
Telecom = "telecom" // 中国电信
|
|
|
|
|
Broadnet = "broadnet" // 中国广电
|
|
|
|
|
Virtual = "virtual" // 虚拟
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ChinaMobile 验证手机号码
|
|
|
|
@ -18,19 +19,23 @@ const (
|
|
|
|
|
func ChinaMobile(number string) (status bool, operator string) {
|
|
|
|
|
status = ChinaMobileNumber(number) // 中国移动运营商
|
|
|
|
|
if status {
|
|
|
|
|
return status, mobile
|
|
|
|
|
return status, Mobile
|
|
|
|
|
}
|
|
|
|
|
status = ChinaUnicomNumber(number) // 中国联通运营商
|
|
|
|
|
if status {
|
|
|
|
|
return status, unicom
|
|
|
|
|
return status, Unicom
|
|
|
|
|
}
|
|
|
|
|
status = ChinaTelecomNumber(number) // 中国电信运营商
|
|
|
|
|
if status {
|
|
|
|
|
return status, telecom
|
|
|
|
|
return status, Telecom
|
|
|
|
|
}
|
|
|
|
|
status = ChinaBroadnetNumber(number) // 中国广电运营商
|
|
|
|
|
if status {
|
|
|
|
|
return status, Broadnet
|
|
|
|
|
}
|
|
|
|
|
status = ChinaVirtualNumber(number) // 虚拟运营商
|
|
|
|
|
if status {
|
|
|
|
|
return status, virtual
|
|
|
|
|
return status, Virtual
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -62,12 +67,20 @@ func ChinaTelecomNumber(number string) bool {
|
|
|
|
|
return reg.MatchString(number)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ChinaBroadnetNumber 验证中国广电手机号码
|
|
|
|
|
// https://www.qqzeng.com/tongji.html
|
|
|
|
|
// 广电:192
|
|
|
|
|
func ChinaBroadnetNumber(number string) bool {
|
|
|
|
|
regular := "^[1](([9][2]))[0-9]{8}$"
|
|
|
|
|
reg := regexp.MustCompile(regular)
|
|
|
|
|
return reg.MatchString(number)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ChinaVirtualNumber 验证虚拟运营商手机号码
|
|
|
|
|
// https://www.qqzeng.com/tongji.html
|
|
|
|
|
// 移动/联通/电信: 162 165 167 170 171
|
|
|
|
|
// 广电:192
|
|
|
|
|
func ChinaVirtualNumber(number string) bool {
|
|
|
|
|
regular := "^[1](([6][2,5,7])|([7][0-1])|([9][2]))[0-9]{8}$"
|
|
|
|
|
regular := "^[1](([6][2,5,7])|([7][0-1]))[0-9]{8}$"
|
|
|
|
|
reg := regexp.MustCompile(regular)
|
|
|
|
|
return reg.MatchString(number)
|
|
|
|
|
}
|
|
|
|
|