For the record Shawn: I received your previous post from Aug 22 and I
think that it is the best solution.
Jonathan
On Tue, Aug 25, 2009 at 12:41 AM, Shawn McKenzie wrote:
> hack988 hack988 wrote:
>> Use preg_replace_callback instead!
>> preg_replace_callback is better performance than preg_repla
hack988 hack988 wrote:
> Use preg_replace_callback instead!
> preg_replace_callback is better performance than preg_replace with /e.
> -
> code
>
> $str="cats i saw a cat and a dog";
> $str1=preg_replace_callback("/(
Use preg_replace_callback instead!
preg_replace_callback is better performance than preg_replace with /e.
-
code
$str="cats i saw a cat and a dog";
$str1=preg_replace_callback("/(dog|cat|.)/is","call_replace",$str);
On Sat, Aug 22, 2009 at 12:32 PM, ÈýÏÝÂÔ 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
Negating specific words with regexes isn't a good practice (see a deep
discussion here: http://www.perlmonks.org/?node_id=588315), in your
case I would resolve it like this:
That will output:
array(5) {
[0]=>
string(3) "cat"
[1]=>
string(10) "s i saw a "
[2]=>
string(3) "cat"
[3]=
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?
--
Use ROT26 for best security
6 matches
Mail list logo