xxxxxxxxxx
// Author : Mahmmoud Kinawy
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
xxxxxxxxxx
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
//will validate for: test@gmail.com etc
xxxxxxxxxx
// This is by far the best regex used for email
^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
xxxxxxxxxx
# regrex for email for javascript
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
xxxxxxxxxx
const EMAIL_PATTERN =
/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
xxxxxxxxxx
let regex = new RegExp("([!#-'*+/-9=?A-Z^-~-]+(\.[!#-'*+/-9=?A-Z^-~-]+)*|\"\(\[\]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(\.[!#-'*+/-9=?A-Z^-~-]+)*|\[[\t -Z^-~]*])");
xxxxxxxxxx
package main
import (
"fmt"
"regexp"
)
func IsValidPhoneEmail(value interface{}) bool {
var (
phonePattern string = `^\+?[0-9]\d{1,20}$`
emailPattern string = `^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-]+)(\.[a-zA-Z]{2,5}){1,2}$`
)
if isPhoneMatch, _ := regexp.MatchString(phonePattern, fmt.Sprintf("%v", value)); isPhoneMatch {
return true
} else if isEmailMatch, _ := regexp.MatchString(emailPattern, fmt.Sprintf("%v", value)); isEmailMatch {
return true
}
return false
}
func main() {
// pattern := `^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-]+)(\.[a-zA-Z]{2,5}){1,2}$`
// data := "jamal13@gmail.com"
isMatch := IsValidPhoneEmail(nil)
fmt.Println(isMatch)
}