0
$str = '<div class="rss"><img src="http://www.wired.com/images_blogs/gadgetlab/2013/10/1125_hbogo_660-660x436.jpg" alt="You Can Now Get HBO GO Without Paying for Other Channels">
</div>Fans of';
我試圖弄清<div class="rss"></div>
之後的文本,但是我使用的每個表達式似乎都不起作用。PHP Preg_match匹配一個類並獲得內容後
匹配的.rss
if(preg_match('/^(<div class=\"rss\">[\S\s]+?</div>([\S\s]*)$/i', $item_content, $matches)) {
可能有人請與這個表達式幫助嗎?
本來我有這個表達式匹配的圖像標籤,而不是一個div,這通過使用
if(preg_match('/^(<img[\S\s]+?>)([\S\s]*)$/i', $item_content, $matches)) {
如果有那個'div'內'div'?像'// div [@ class =「rss」]/following-sibling:text()[1]'這樣的xpath似乎更加健壯。 – Wrikken