Re: preg_replace anything that isn't WORD

From: Date: Mon, 24 Aug 2009 13:32:06 +0000
Subject: Re: preg_replace anything that isn't WORD
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-297122@lists.php.net to get a copy of this message
On Sat, Aug 22, 2009 at 12:32 PM, “•ÈýÏݓ•ÂÔ<danondaniel@gmail.com> wrote:
Lets assume I have the string "cats i saw a cat and a dog" i want to strip everything except "cat" and "dog" so the result will be "catcatdog", using preg_replace. I've tried something like /[^(dog|cat)]+/ but no success
What should I do?
Lot's of ways to skin this cat/dog. What's wrong with exploding the string using spaces and then walking the array looking for cat and dog while assembling the resultant string? Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#297122) next »