Re: Reject some?

From: Date: Mon, 16 Dec 2002 19:10:10 +0000
Subject: Re: Reject some?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128459@lists.php.net to get a copy of this message
On Tuesday 17 December 2002 02:46, Gerard Samuel wrote: > What Im trying to do is, reject all email address strings ending in > yahoo.com, except 08701@yahoo.com. > Im trying -> > <?php > > if (preg_match('/[^08701@yahoo.com|yahoo.com]$/', '08702@yahoo.com')) > { > echo 'match found'; > } > else > { > echo 'match not found'; > } > > ?> > > The search pattern must also be capable of expanding to something like -> > ^08701@yahoo.com|yahoo.com|^foo@hotmail|hotmail.com > Basically what Im trying to perform is to reject all email address > strings ending in either yahoo.com or hotmail.com, > except strings ending in 08701@yahoo.com or foo@hotmail.com. I'm not going to try writing the regex for you, but I can point out at least two problems with it: 1) ^ inside square brackets means logical NOT 2) A period (.) means "any character". If you want to match a literal period you need to escape it using a backslash. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* There's something the technicians need to learn from the artists. If it isn't aesthetically pleasing, it's probably wrong. */

« previous php.general (#128459) next »