Re: [問題] 夾在中間的字

看板RegExp (正規表示式 Regular Expression)作者 (亞修)時間14年前 (2010/11/19 14:29), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
※ 引述《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
文章代碼(AID): #1CvXan2X (RegExp)
討論串 (同標題文章)
文章代碼(AID): #1CvXan2X (RegExp)