Validate an Email Address using Regex
This function validates an email address passed to it and returns either True or False.
function validate_email($email) {
$match = "/^[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_+])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}$/";
$regex = preg_match($match, $email);
return $regex;
}
Posted at 6:52 on 5 rd July 2009