正则: "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\d{8}$"
Kotlin代码
fun regexPhone(phone: String): Boolean {
var mainRegex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,1,2,3,5-9])|(177))\\d{8}$"
var p = Pattern.compile(mainRegex)
val m = p.matcher(phone)
return m.matches()
}
参考:
https://blog.csdn.net/m18860232520/article/details/79396889
网友评论