Re: String Replacement

From: Date: Mon, 15 Jan 2001 06:06:03 +0000
Subject: Re: String Replacement
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-5019@lists.php.net to get a copy of this message
On 14 Jan 2001 19:40:28 -0800, Toby Butzon <php-lists@imawebdesigner.com> wrote: >Ok, so you want to replace ONLY the word "boy" with the word "girl"... you >don't want to touch "boys". > >Perhaps str_replace("boy ", "girl ", $myStr) would do the trick? Better yet, preg_replace("/\bboy\b/i", "girl", $myStr) or ereg_replace("[[:space:][:punct:]]boy[[:space:][:punct:]]", "girl", $myStr). Those would also match things like "boy,", "boy:" or "boy)".

« previous php.windows (#5019) next »