element Posted October 18, 2006 Report Share Posted October 18, 2006 (edited) Iespeejams kaadam jau ir gatavs risinaajums vai kaads paraugs vai ideja tam kaa no $teksts mainiigaa izdzeest visu lieko infu (dzeest atkaartotos simbolus vai simbolu virkni), piemeeram: 1) aaaaaaaaaa => a 2) ababababab => ab 3) abbabbabba => abba 4) abcabcabcabc => abc Edited October 18, 2006 by element Link to comment Share on other sites More sharing options...
v3rb0 Posted October 18, 2006 Report Share Posted October 18, 2006 unikālos burtus ar $str = implode('',array_unique(preg_split('//',$str))) atkārtotās virknes - tur parāk maz nosacījumu ko uzskatīt par virknes sākumu, ko par virknes beigām. Link to comment Share on other sites More sharing options...
bubu Posted October 18, 2006 Report Share Posted October 18, 2006 Var arī ar vienkāršu regexpu izmantojot preg_replace un back references. Tb simbolu gadījumā kautkā šādi: preg_replace('/(.)(\1+)/', '\1', $text). Simbolu virknes gadījumā iespējams arī var tāpat darīties, papildus pieliekot ungreedy flagu (tb tiks meklēta pēc iespējas īsāka virkne). Link to comment Share on other sites More sharing options...
element Posted October 18, 2006 Author Report Share Posted October 18, 2006 (edited) vai ir iespeejams panjemt no abcabcabcabc pirmos 3 abc un saliidzinaat ejot no 1 stringa poziicijas liidz peedeejai un saliidzinaat no 1 liidz 3 pzoiicijai esoshos simbolus ar stringa fragmentu? ar $str = implode('', array_unique(preg_split('//',$str))); 'juris gaaja uz skolu' => 'juris gazkol' protams shis buutu variants, bet nav jau ideju kaa atshkjirt lietotaaja spamu no normaalas stringu virknes. (ja nu vieniigi peec taa cik garsh ir katrs vaards?) Edited October 19, 2006 by element Link to comment Share on other sites More sharing options...
kerz Posted October 18, 2006 Report Share Posted October 18, 2006 (edited) $preg = array( 'aaaaa' => "a", 'abababa' => "ab", 'utt..' => "..", iesmpējams ka šādi, bet iespējams ka kaut kas trūkst.. Pieviena uzjautāšu kādam kas zin. Vai šajā funkcijā var izmantot arī js? piem: $preg = array( '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a onClick="window.open('<?php echo $row[address]; ?>', 'mywindow', 'location=0,width=550,height=650,titlebar=0,toolbar=0,hotkeys=0')">", Edited October 18, 2006 by kerz Link to comment Share on other sites More sharing options...
andrisp Posted October 18, 2006 Report Share Posted October 18, 2006 kerz, vai tad tur jau nav js ? Link to comment Share on other sites More sharing options...
kerz Posted October 18, 2006 Report Share Posted October 18, 2006 ir jau bet tā nedarbojas! Link to comment Share on other sites More sharing options...
andrisp Posted October 18, 2006 Report Share Posted October 18, 2006 Ko nozīmē "nedarbojas" ? php errors, javascripti errori ? Link to comment Share on other sites More sharing options...
kerz Posted October 19, 2006 Report Share Posted October 19, 2006 pat erroru neuzmet Link to comment Share on other sites More sharing options...
Recommended Posts