Regex help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx";
$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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux