You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
505 B

package regx
import "regexp"
// 校验邮件地址有效性
func (rr *Regx) IsMail(mail string) bool {
pattern := `^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z]\.){1,4}[a-z]{2,4}$`
reg := regexp.MustCompile(pattern)
return reg.MatchString(mail)
}
// IsEmail check if the string is a email address.
func (rr *Regx) IsEmail(email string) bool {
var isEmailRegexMatcher = regexp.MustCompile(`\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`)
return isEmailRegexMatcher.MatchString(email)
}