In PHP you don't need a monster regex like that, you can just use the built-in validator: http://www.php.net/manual/en/filter.examples.validation.php
For example, only the first echo
will be executed:
<?php
$email_a = 'joe@example.com';
$email_b = 'bogus';
if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
echo "This ($email_a) email address is considered valid.";
}
if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
echo "This ($email_b) email address is considered valid.";
}
?>