作者guardlan (亚修)
看板RegExp
标题Re: [问题] 夹在中间的字
时间Fri Nov 19 14:29:03 2010
※ 引述《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