RE: [PHP] Matching valid e-mail address

From: Date: Mon, 11 Sep 2000 09:44:57 +0000
Subject: RE: [PHP] Matching valid e-mail address
Groups: php.general 
Request: Send a blank email to php-general+get-16139@lists.php.net to get a copy of this message
if you go to php.net and look for ereg() the users there contribuited lots of coeds throught which I saw an email validator... or go to http://www.phpbuilder.com/columns/dario19990616.php3 where example on learning RegEx is in fact an email validator ... Hope it will help you somehow... -----Original Message----- From: Tero Ripattila [mailto:tero.ripattila@nic.fi] Sent: Monday, September 11, 2000 6:42 PM To: php-general@lists.php.net Subject: [PHP] Matching valid e-mail address 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#16139) next »