Re: /i modifier with preg_replace

From: Date: Tue, 03 Apr 2001 12:45:09 +0000
Subject: Re: /i modifier with preg_replace
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-6459@lists.php.net to get a copy of this message
Thanks Carsten & Daniel...that works. Daniel... that (?<!\S) bit will be really useful to me later on in a forum that I'm writing for my college... it'll censor swear words like c*nt but I don't want it to touch town names and such like Scunthorpe. So I'll be keeping that little code snippet! :) Thanks a lot folks. :) -- Matt matthew.ralston@haltoncollege.ac.uk matthew@ralston.net < www.mralston.co.uk /> "Daniel Beulshausen" <daniel@php4win.de> wrote in message news:5.0.2.1.2.20010403111335.00a74818@pop.puretec.de... > At 09:32 03.04.2001 +0100, Matthew wrote: > >Hello... > > > >I'm trying to implement a case insensitive str_replace (bearing in mind that > >I'll be performing the replace on a paragraph of text so I don't want to > >convert it all to upper or lower case first). > > > >Somebody suggested using the /i modifier with pregreplace but I don't know > >where to put the modifier... i've put an example bit of code below, can > >somebody please put the modifier in its rightful place for me? > > > >$print preg_replace("test", "this is a test", "test TEST tEsT > >TEst") > > print preg_replace("/test/i", "this is a test", "test TEST tEsT > TEst"); > or you might try '/(?<!\S)test(?!\S)/i' to replace only occurences of test > and don't want to touch "betatester" > > http://www.amazon.com/exec/obidos/ASIN/1565922573 is a > "must have" for most > programmers. > > daniel > > /*-- > daniel beulshausen - daniel@php4win.de > using php on windows? http://www.php4win.de > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.windows (#6459) next »