xxxxxxxxxx
const validateEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.toLowerCase());
xxxxxxxxxx
function validateEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\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,}))$/;
return re.test(String(email).toLowerCase());
}
xxxxxxxxxx
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
//will validate for: test@gmail.com etc
xxxxxxxxxx
1) js
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
2) using in angular
ng-pattern="mailformat"
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)
}
xxxxxxxxxx
// Simple and very useful regex. Just Pass your email whare is email here
const regex = /\S+@\S+\.\S+/
regex.test(email here)
xxxxxxxxxx
const EMAIL_PATTERN =
/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
xxxxxxxxxx
// This is by far the best regex used for email
^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$