MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / IsValidNumber

Function IsValidNumber

utils/sms.go:19–25  ·  view source on GitHub ↗

IsValidNumber 检查给定的字符串是否符合中国的手机号格式

(number string)

Source from the content-addressed store, hash-verified

17
18// IsValidNumber 检查给定的字符串是否符合中国的手机号格式
19func IsValidNumber(number string) bool {
20 // 中国的手机号通常是以1开头的11位数字
21 // 这个正则表达式匹配以1开头,第二位是3、4、5、6、7、8、9中的一个,后面跟着9位数字的字符串
22 pattern := `^1[3456789]\d{9}$`
23 matched, _ := regexp.MatchString(pattern, number)
24 return matched
25}

Callers 1

SendSMSMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected