Re: replacing strings... (hope it isn't too basic...)

From: Date: Fri, 25 Jul 2003 14:14:23 +0000
Subject: Re: replacing strings... (hope it isn't too basic...)
References: 1 2 3 4  Groups: php.windows 
Request: Send a blank email to php-windows+get-20904@lists.php.net to get a copy of this message
Bobo Wieland wrote: > Q1 :If I'm for example is going to replace all occurences of "foo" in > the following sentence with "bar" in case-insensetiv manner how would > I do it? > > "Foo foo foo Foo fOO fOo" should be replaced with "Bar bar bar > Bar bAR bAr"... > > I guess I would need regular expressions? Right? hi, this should work. $barString = preg_replace('/foo/i', 'bar', $fooString); if you only want to match 'foo' but not foofoo, you have to use '/\Wfoo\W/i' ciao SVEN

« previous php.windows (#20904) next »