正则 PHP JavaScript HTML
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>s+\<\/h4\>/is";//。。。。
<h4> <a id="4658205654481332717" istitle="true" href="javascript:void(0);" onclick="makeDetailUrl(this, '/search/showDocDetails?', '4658205654481332717', 'ucs09', 'PHP');" target="_blank"> PHP </a> </h4>
\s 写成了 s
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";
其实这样写好点
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>[\s\S]*\<\/h4\>/is";//。。。。
\s 写成了 s
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";
其实这样写好点
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>[\s\S]*\<\/h4\>/is";//。。。。
问一下,修饰符s用了之后,直接抓到低结束不了,比如说我想在这里结束,需要用什么来声明吗?
$s =<<< TXT<h4> <a id="4658205654481332717" istitle="true" href="javascript:void(0);" onclick="makeDetailUrl(this, '/search/showDocDetails?', '4658205654481332717', 'ucs09', 'PHP');" target="_blank"> PHP </a> </h4>TXT;$pattern_Title = '#target="_blank">(.*)</a>\s+</h4>#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
$pattern_Title = '#target="_blank">\s*(.*)\s*</a>#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
其实这样写好点
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>[\s\S]*\<\/h4\>/is";//。。。。
$s =<<< TXT<h4> <a id="4658205654481332717" istitle="true" href="javascript:void(0);" onclick="makeDetailUrl(this, '/search/showDocDetails?', '4658205654481332717', 'ucs09', 'PHP');" target="_blank"> PHP </a> </h4>TXT;$pattern_Title = '#target="_blank">(.*)</a>\s+</h4>#is';preg_match_all($pattern_Title, $s, $r);print_r($r);
$pattern_Title = "/target=\"\_blank\"\>.*\<\/a\>\s+\<\/h4\>/is";