On Tue, 21 May 2002, Denis L. Menezes wrote:
> I use the following code, but it does not work. Is there something wrong?
> 
> If
> (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a
> -z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> $email_address))

One problem (syntax issues aside) is that it doesn't seem to be checking
for anything remotely similar to a valid email address.

Here's what we use. Not 100% perfect but closer than most, I think:

function validate_email ($addr)
{
  return
    
preg_match('/^[^\'"\s,;]+@([a-z0-9]+[a-z0-9\-]*\.)+[a-z0-9]+[a-z0-9\-]*[a-z0-9]+$/i',
      trim($addr)));
}

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to