waplet Posted January 30, 2010 Report Share Posted January 30, 2010 <img class="bildes" src="test" alt="test"> <img class="bildes" src="test1" alt="test1"> Kā lai ar Regexp izravē to , kas ir iekš alt="" , kur class="bildes"? vai tas vispār ir iespējams? Link to comment Share on other sites More sharing options...
2easy Posted January 30, 2010 Report Share Posted January 30, 2010 (edited) vsp ir iespējams ^^ $s = 'bla bla bla <img class="bildes" src="test" alt="test">' . 'lalala <img class="bildes" src="test1" alt="test1">'; preg_match_all('/<img class="bildes" src="[^"]+" alt="([^"]*)">/', $s, $m); echo '<pre>' . print_r($m[1], 1) . '</pre>'; /* Array ( [0] => test [1] => test1 ) */ briedi, es pirmais :P nice code contest :D Edited January 30, 2010 by 2easy Link to comment Share on other sites More sharing options...
briedis Posted January 30, 2010 Report Share Posted January 30, 2010 (edited) <img class="bildes" src="test" alt="test"> <img class="bildes" src="test1" alt="test1"> Kā lai ar Regexp izravē to , kas ir iekš alt="" , kur class="bildes"? vai tas vispār ir iespējams? Paprovēju, sanāca kkas šitāds: $result = preg_replace('/<img([^>]*)(class="bildes"[^>]*)alt="[^"]*"([^>]*)>/', '<\\1alt=""\\2>', $subject); Iepsējams, ka var labāk, neesmu vnk specs regexpos... EDIT: :p mans stradās arī ja class="bildes" būs aiz cita atribūta :p Edited January 30, 2010 by briedis Link to comment Share on other sites More sharing options...
2easy Posted January 30, 2010 Report Share Posted January 30, 2010 (edited) oops, abloms izravēt bija domāts, nevis get, bet delete? vnk man likās, kāds tolks kko dzēst. it kā kko dabūt būtu lietderīgāk. vismaz kkāds praktisks ieguvums, tipa informācija opredelajsja waplet :D Edited January 30, 2010 by 2easy Link to comment Share on other sites More sharing options...
waplet Posted January 30, 2010 Author Report Share Posted January 30, 2010 Nu izravēt manā gadījumā vajadzeja - dabūt arā listi ar tiem alt'iem. pareizi bija kā 2easy.. bija domājis. Link to comment Share on other sites More sharing options...
briedis Posted January 30, 2010 Report Share Posted January 30, 2010 skaidrs, pārpratu :) Link to comment Share on other sites More sharing options...
2easy Posted January 30, 2010 Report Share Posted January 30, 2010 man jau likās, ka es pārpratu, un tūlīt būs briedis vs 2easy 1 : 0 :D:D:D Link to comment Share on other sites More sharing options...
waplet Posted January 30, 2010 Author Report Share Posted January 30, 2010 Beidzam dzīt offtopiku... >> PM Link to comment Share on other sites More sharing options...
Recommended Posts