移动联通电信手机号段和正则表达式,附号段表

mobileexp:=`(^((13[4-9]|14[7-8]|15[0-27-9]|17[28]|18[2-47-8]|198)\d{8})$)|(^((170[35-6]|1440)\d{7})$)`
unicomexp:=`(^((13[0-2]|14[05-6]|15[5-6]|166|17[15-6]|18[5-6])\d{8})$)|(^(170[47-9]\d{7})$)`
telcomexp:=`(^((133|149|153|17[37]|18[0-19]|199)\d{8})$)|(^((170[0-2]|1349|1410)\d{7})$)|(^(1740[0-5]\d{6})$)`

//golang测试
func TestMobile(t *testing.T) {

	mobileexp:=`(^((13[4-9]|14[7-8]|15[0-27-9]|17[28]|18[2-47-8]|198)\d{8})$)|(^((170[35-6]|1440)\d{7})$)`
	//unicomexp:=`(^((13[0-2]|14[05-6]|15[5-6]|166|17[15-6]|18[5-6])\d{8})$)|(^(170[47-9]\d{7})$)`
	//telcomexp:=`(^((133|149|153|17[37]|18[0-19]|199)\d{8})$)|(^((170[0-2]|1349|1410)\d{7})$)|(^(1740[0-5]\d{6})$)`
	reg := regexp.MustCompile(mobileexp)
	ok:=reg.MatchString("17046988981")
	if ok {
		println("china mobile")
	}else {
		println("NOT china mobile")
	}
}

附表
在这里插入图片描述

发布了2 篇原创文章 · 获赞 1 · 访问量 1210

猜你喜欢

转载自blog.csdn.net/sinat_36797467/article/details/102521829