Regex to Test for Email Address in PHP

February 25, 2014

This is a simple function in PHP to determine if a string is a valid email address.

/**
 * Check if a string is a valid email address.
 * @param string Email address.
 */
function is_email($address)
{
   return (ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $address));
}

Related Posts