你好,我的模式是:
'<span\s+id="bodyHolder_newstextDetail_nwstxtPicPane"><a\s+href="(.*)"\s+target="_blank"><img\s+alt="(.*)"\s+title="(.*)"\s+src=\'(.*)\'\s+/>'
和字符串:
<div class="nwstxtpic">
<span id="bodyHolder_newstextDetail_nwstxtPicPane"><a href="xxxxx" target="_blank"><img alt="xxxxx" title="xxxxx" src='xxxxx' />
好吧,我用于查找和获取我在 patern 中定义的 4 个组的值的 php 代码是:
$picinfo=preg_match_all('/<span\s+id="bodyHolder_newstextDetail_nwstxtPicPane"><a\s+href="(.*)"\s+target="_blank"><img\s+alt="(.*)"\s+title="(.*)"\s+src=\'(.*)\'\s+/>/',$newscontent,$matches);
foreach ($matches[0] as $match) {
echo $match;
}
我不知道如何获得这4组的价值
href="(.*)"
alt="(.*)"
title="(.*)"
src=\'(.*)\'
请你帮帮我?谢谢你。