Re: regular expression

From: Date: Mon, 15 Jan 2001 10:55:41 +0000
Subject: Re: regular expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34604@lists.php.net to get a copy of this message
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

« previous php.general (#34604) next »