How do I specify the regular expression to disable the use of underscores after the '@' sign in php for email validation?
- by Qlidnaque
Currently the following email in the script validates even though there are no underscores indicated in the second part of the regular expression validation after the '@' sign. How do I make underscores invalid in the second part of the email?
<?php
$email = 'firstname.lastname@a_aa.bbb.co_m';
$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9]+([.][A-z0-9]+)*[.][A-z]{2,4}$/";
if (preg_match($regexp, $email)) {
echo "Email address is valid.";
} else {
echo "Email address is <u>not</u> valid.";
}
?>