smarty Posted May 17, 2005 Report Share Posted May 17, 2005 probleema shaada: ir teksts, piemeeram aaa bbbb ccc "ddd eee" fff ir nepiecieshams izdabuut noshaa stringa massiivu, kuram eleementi buutu, piemeeram,$arr[] = 'aaa';$arr[] = 'bbbb'; $arr[] = 'ccc'; $arr[] = 'ddd eee'; $arr[] = 'fff'; viss buutu labi, ja nebuutu to peedinju, jo ar taam apziimee vienu elementu. Link to comment Share on other sites More sharing options...
рпр Posted May 17, 2005 Report Share Posted May 17, 2005 kaadas probleemas ar explode to izdariit? Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 es tak saku, ja nebuutu kjeepa ar pedinjaam tad nebuutu probleemu Link to comment Share on other sites More sharing options...
bubu Posted May 17, 2005 Report Share Posted May 17, 2005 Vobšem šitais variants tīri labs, atliek tikai no pēdiņām atbrīvoties: <?php $a = 'aaa bbbb ccc "ddd eee" fff'; preg_match_all('@\w+|"[\w\s]+"@i', $a, $m); print_r($m); ?> --- Array ( [0] => Array ( [0] => aaa [1] => bbbb [2] => ccc [3] => "ddd eee" [4] => fff ) ) Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 thanx bubu :o Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 + veel viena liidiziga probleeminja vajag no teksta izmest aaraa tukshaas rindas, kuras atkaartojas piemeers, ir teksts asdasdasasds sdddssd asdasdassadas rezultaatam jaabuutasdasdasasds sdddssd asdasdassadas ieverojot ka taas daudzaas jaaizstaaj ar vienu meegjinaaju ar preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\r\n", $body); bet tas aizvaac visas.. Link to comment Share on other sites More sharing options...
Venom Posted May 17, 2005 Report Share Posted May 17, 2005 str_replace("\n\n","\n",$text), ja nepieciešams, while(strpos($text,"\n\n")!==false) Link to comment Share on other sites More sharing options...
bubu Posted May 17, 2005 Report Share Posted May 17, 2005 preg_replace("@[\r\n]{2,}@m", "\r\n", $text); Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 abi varianti nestraadaa pirmais taapeec ka jaanjem veeraa ka breaks var buut \r\n otrs visas rindas aizvaac <_< Link to comment Share on other sites More sharing options...
bubu Posted May 17, 2005 Report Share Posted May 17, 2005 hmm, man nezkāpēc mans piemērs strādā... Īsti nesapratu, tev vajag visus enterus, kuri atkārtojās aizstāt ar vienu (kam arī rakstīju to regexpu)? Vai ja ir 3 vai vairāk enter, tad aizstāt tos ar diviem? Ja pēdējais variants, tad takš loģiski drusku pamaini izteiksmi: preg_replace("@[\r\n]{3,}@m", "\r\n\r\n", $text); Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 aa re kaa :) ir ok Link to comment Share on other sites More sharing options...
smarty Posted May 17, 2005 Author Report Share Posted May 17, 2005 labi, ja jau shodien par to iesaaku, tad gribu pabeigt liidz galam. man tagad ir preg_match_all('@[\wēūīōāšģķļžčņ]+|"[\wēūīōāšģķļžčņ\s]+"@ui', ... bet ja man vajag atljaut arii nestandarta simbolus? (vispaar visus iznjemot speisu) vai ir kaads veids kaa to te panaakt? Link to comment Share on other sites More sharing options...
bubu Posted May 17, 2005 Report Share Posted May 17, 2005 laikam šādi: preg_match_all('@\S+|"[^\s"]+"@', ... Link to comment Share on other sites More sharing options...
smarty Posted May 20, 2005 Author Report Share Posted May 20, 2005 ehh nestraadaa shis variants Link to comment Share on other sites More sharing options...
bubu Posted May 20, 2005 Report Share Posted May 20, 2005 ehh nestraadaa shis variants 17750[/snapback] Nu ja nestrādā, tad jākustina smadzenes un jādomā jauns variants, nevis smagi jāpūš: preg_match_all('@"[^"]+"|\S+@', ... ); Link to comment Share on other sites More sharing options...
Recommended Posts