dille Posted April 25, 2004 Report Share Posted April 25, 2004 man ir shaads jautaajiens: kaa ar PHP paliidziibu kaut kaadaa stringaa var dzeest tos simbolus, kuri atkaartojaas vairaak kaa 3x peec kaartas? Piemeeram, ir strings "ksd dfkjg..........########", rezultaataa vajadzeetu dabuut "ksd dfkjg...###" un veel, kaa tad, ja nepiecieshams dzeest simbolu grupu, kas atkaartojaas, piemeeram, "hahahahahahahahahahaha" vajadzeetu dabuut par "hahaha" paldies Link to comment Share on other sites More sharing options...
bubu Posted April 25, 2004 Report Share Posted April 25, 2004 manuaalii nedomaaji skatiitities: $result = str_replace('###', '#', 'ksd dfkjg..........########'); $result2 = str_replace('hahaha', 'ha', 'hahaha...hahaha'); Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 (edited) 2 bubu: Nebūs tik vienkārši. Kā lai viņš iepriekš zin, kas ir jāsaīsina ("ha" "ma" "la" vai "fa")? Edited April 25, 2004 by Aleksejs Link to comment Share on other sites More sharing options...
dille Posted April 25, 2004 Author Report Share Posted April 25, 2004 bubu, tu domaa, ka es tagad visus miljons variantus scriptaa noraadiishu ;) vajag, lai tiktu njemts veeraa jebkursh simbols (vai simbolu virkne 2. gadiijumaa) nevis viens noteikts simbols Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 2 dille: Atbilde ir regular expressions, kuras, diemžēl, pārzinu pietiekami vāji, lai dotu kādu sakarīgu padomu. pameklē vārdu regex forumā un googlē - šī tēma (vai vismaz ļoti līdzīga) ir jau apspriesta. Link to comment Share on other sites More sharing options...
Recommended Posts