Problem Statement:
Regular Expression function to validate email addresses.
Dependencies:
None
Example Usage:
if (is_email("me@foobar.com")) {
// Do some stuff
}
/**
* validates that a string is a well-formed email address
* @param string The string to validate
* @return bool Whether or not the string was a well-formed email address
*/
function is_email($email) {
return eregi(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$email
);
}