Re: [HAB] str_replace
| From: | Jochem Maas | Date: | Tue, 22 Feb 2005 21:41:11 +0000 |
| Subject: | Re: [HAB] str_replace | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-209198@lists.php.net to get a copy of this message | ||
Bret Hughes wrote:
On Tue, 2005-02-22 at 09:59, OOzy Pal wrote:echo preg_replace("/{\!(.*)\!}/","{!REPLACED!}","erg9872et {!---SUPERDUPER---!}gjhgo6*%^*&^%Y)7ygr9 y2343");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 youIIRC 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.