Regex help

From: Date: Tue, 02 Aug 2005 13:08:04 +0000
Subject: Regex help
Groups: php.general 
Request: Send a blank email to php-general+get-219819@lists.php.net to get a copy of this message
I'm trying to validate an email address and for the life of me I cannot figure out why the following regex is not working: <script language="php"> $email = "f.lastname@company-di.co.uk"; $regex = "^([a-zA-Z0-9_\.\-\']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-\']+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; if( ereg( $regex, $email )) { echo 'Good email address'; } else { echo 'Bad email address'; } </script> Does anyone have any ideas? thnx, Chris

« previous php.general (#219819) next »