On Monday 15 January 2001 09:03, Fai wrote:
> ^.+@.+\\..+$  This regular expression can check if the email address is
> valid. But it cannot validate the email address with two "@", does

I use this code:

/*
 * Check whether the supplied string is a
 * (syntactically) valid email address
 * Only does a very rough check. Checking for complete
 * validity is nearly impossible.
 */
function pbIsMailAddress ($Address)
{
        // strip comments
        while (preg_match ('/\([^()]*\)/', $Address))
                $Address = preg_replace ('/\([^()]*\)/', '', $Address);

        // strip leading/trailing whitespace
        $Address = trim ($Address);

        // check for basic form
        return preg_match ('/^[^@]+@[\w-]+(\.[\w-]+)+$/', $Address);
}

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"Software is like sex: the best is for free" -- Linux Torvalds

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to