I'm using the following function to determine if an e-mail is valid. I have a customer with an e-mail address that has a hyphen in the domain name: Example@some-thing.com and it's coming back as invalid. Unfortunately, I don't understand regex. Could someone help me fix it to accept his e-mail?
function isValidEmail($email)
{
$regex = "/([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)@(([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4}))/i";
if(!preg_match($regex, $email)) {
return false; }
else {
return true;
}
}