看板 RegExp 關於我們 聯絡資訊
※ 引述《frsnic (路人)》之銘言: : <a rel="mid_name" href="http://xxxxx" title="書名"> : 請問這要怎麼抓出書名 ~"~ 改了一個早上還是弄不出來 : 我是用php的preg_match ============================================= 程式: ============================================= $string = '<a rel="mid_name" href="http://xxxxx" title="書名">'; preg_match('/<a rel=\"[^\"]*\" href=\"[^\"]*\" title=\"([^\"]*)\"[^\>]*\>/', $string, $matches); print_r($matches); ============================================= 結果: ============================================= Array ( [0] => <a rel="mid_name" href="http://xxxxx" title="書名"> [1] => 書名 ) 如果你要解析的文章有很多 <a rel="mid_name" href="http://xxxxx" title="書名"> 這種東西的話 請用 preg_match_all 才能抓到很多個 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.36.168.98