Matching valid e-mail address

From: Date: Mon, 11 Sep 2000 09:41:34 +0000
Subject: Matching valid e-mail address
Groups: php.general 
Request: Send a blank email to php-general+get-16137@lists.php.net to get a copy of this message
HI! I borrowed an example offered in this newsgroup some time ago and expanded it a little. I managed to get the function to accept an underscore (_) before the @-sing, but can't make it acceptable by the function after the @-sign. Could some Perl-guru give me a helping hand ?-) Here is the script: function check_email_syntax($email) { if( eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $email) || !eregi("^.+\@(\[?)[-a-zA-Z0-9\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$", $email)) { return(false); } else { list($user, $domain) = explode("@", $email); if ( (!eregi("^[a-zA-Z0-9\_\.\-]+$", $user)) || (!eregi("^[a-zA-Z0-9\_\.\-]+$", $domain))) { return(false); } else { return(true); } } } Tero Ripattila

« previous php.general (#16137) next »