golang正则验证邮箱格式


 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("12345@126.com")) //true
 9     fmt.Println(VerifyEmailFormat("12345126.com"))  //false
10 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM