On Tue, 2005-02-22 at 09:59, OOzy Pal wrote: > Dears > > I am trying replace anything between '{!' and '!}' i.e {!A!} and {!B!} > and {!ABC!} with XYZ. I tried the following but no help. Can anyone > help? > > $this->template=str_replace("{!*!}","XYZ",$this->template); > > Thank you > > IIRC str_replace does not use any type of globbing. You need to use one of the function that uses regular expresions I prefer preg_replace personally. regexes can get complicated looking pretty quick but are an incredibly powerful mechanism once you understand even the rudiments. I would place my self in that catagory. try something like : $this->template = preg_replace ("/![^!]*!/","!XYZ!",$this->template); untested but should be close. what the /![^!]*!/ says is match any string that starts with a ! and is followed by zero or more characters that are not ! followed by a ! the replacement part of the function replaces it all with !XYZ!. this will also catch the string !! and replace it with !XYZ! if this is not what you want replace the * above with + (one or more) exactly one char between them leave the * off altogether. HTH Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php