1 func VerifyEmailFormat(email string) bool { 2 pattern := `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*` //匹配电子邮箱 3 reg := regexp.MustCompile(pattern) 4 return reg.MatchString(email) 5 } 6 7 func main() { 8 fmt.Println(VerifyEmailFormat("[email protected]")) //true 9 fmt.Println(VerifyEmailFormat("12345126.com")) //false 10 }
golang正则验证邮箱格式
猜你喜欢
转载自www.cnblogs.com/chaselogs/p/10072430.html
今日推荐
周排行