帮忙写个正则表达式
<dd class="clear">
<a target="_blank" title="爱丽丝cos" href="/cp/sK7A9su_Y29z.html">爱丽丝cos</a>
<a target="_blank" title="爱丽丝连衣裙" href="/cp/sK7A9su_wazSwsi5.html">爱丽丝连衣裙</a>
<a target="_blank" title="爱丽丝梦游仙境" href="/cp/sK7A9su_w87Tzs_JvrM.html">爱丽丝梦游仙境</a>
<a target="_blank" title="爱丽丝疯狂回归" href="/cp/sK7A9su_t-i_8bvYuek.html">爱丽丝疯狂回归</a>
<a target="_blank" title="爱丽丝花盆" href="/cp/sK7A9su_u6jF6A.html">爱丽丝花盆</a>
<a target="_blank" title="爱丽丝手办" href="/cp/sK7A9su_ytaw7A.html">爱丽丝手办</a>
<a target="_blank" title="alice" href="/cp/YWxpY2U.html">alice</a>
<a target="_blank" title="女仆" href="/cp/xa7GzQ.html">女仆</a>
<a target="_blank" title="爱丽丝学园" href="/cp/sK7A9su_0afUsA.html">爱丽丝学园</a>
<a target="_blank" title="爱丽丝菲尔" href="/cp/sK7A9su_t8a2-w.html">爱丽丝菲尔</a>
<a target="_blank" title="爱丽丝手包" href="/cp/sK7A9su_ytaw_A.html">爱丽丝手包</a>
<a target="_blank" title="爱丽丝复古" href="/cp/sK7A9su_uLS5xQ.html">爱丽丝复古</a>
</dd>
$contents_key = '~<a target="_blank" title="(.*?)" href="(.*?)">~';这样会把dd标签外的相同格式的也包含进来,问下这个正则应该怎么写?
preg_match_all($contents_key,$html,$contentskey);
$s=<<<div
agfdafg
<dd class="clear">
<a target="_blank" title="爱丽丝cos" href="/cp/sK7A9su_Y29z.html">爱丽丝cos</a>
<a target="_blank" title="爱丽丝连衣裙" href="/cp/sK7A9su_wazSwsi5.html">爱丽丝连衣裙</a>
<a target="_blank" title="爱丽丝梦游仙境" href="/cp/sK7A9su_w87Tzs_JvrM.html">爱丽丝梦游仙境</a>
<a target="_blank" title="爱丽丝疯狂回归" href="/cp/sK7A9su_t-i_8bvYuek.html">爱丽丝疯狂回归</a>
<a target="_blank" title="爱丽丝花盆" href="/cp/sK7A9su_u6jF6A.html">爱丽丝花盆</a>
<a target="_blank" title="爱丽丝手办" href="/cp/sK7A9su_ytaw7A.html">爱丽丝手办</a>
<a target="_blank" title="alice" href="/cp/YWxpY2U.html">alice</a>
<a target="_blank" title="女仆" href="/cp/xa7GzQ.html">女仆</a>
<a target="_blank" title="爱丽丝学园" href="/cp/sK7A9su_0afUsA.html">爱丽丝学园</a>
<a target="_blank" title="爱丽丝菲尔" href="/cp/sK7A9su_t8a2-w.html">爱丽丝菲尔</a>
<a target="_blank" title="爱丽丝手包" href="/cp/sK7A9su_ytaw_A.html">爱丽丝手包</a>
<a target="_blank" title="爱丽丝复古" href="/cp/sK7A9su_uLS5xQ.html">爱丽丝复古</a>
</dd>
dafdsaf
div;
preg_match('/<dd class="clear">(.+?)<\/dd>/s',$s,$m);
echo $m[1];
<a target="_blank" title="爱丽丝复古" href="/cp/sK7A9su_uLS5xQ.html">爱丽丝复古</a>
[解决办法]
试试用这个匹配dd的内容
$pattern = '/<dd class="clear">.*<\/dd>/is'