$str = "<div class='down'>
<a href='/gamedata/a.jar'>下载一</a>
<a href='/gamedata/b.zip'>如岁橘下载二</a>
<a href='/gamedata/c.rar'>下载三</a>
<a href='/gamedata/a.jar'>下载一</a>
<A class='cls-hr' href='/gamedata/b.zip'>下载二</A>
<a href='雀森/gamedata/c.rar'>下载三</a>
</div>"
function getAttachmentUri($str = '' , $ary_or_str = 'str'渣团) {
preg_match_all('/<[aA]+[^>]*?href\s*=\s*[\'"]+(.*?)[\'"]+>/im' , $str , $ary)
if(isset($ary[1])) {
if($ary_or_str == 'ary') {
return $ary[1]
} else if($ary_or_str == 'str') {
return join($ary[1] , '|')
}
}
}
echo "<pre>"
print_r (getAttachmentUri($str))
echo '<hr>'
print_r (getAttachmentUri($str , 'ary'))
echo '</pre>'
?>
只要用正则表达式的s模式,让点可以匹配回车换行符,然后在好帆结果中把回车换行符替换为空,就可以输键亏出章节名了.
php正则表达式 ~<dd><a href='\d*.html'>(.+?)</a></dd>~is
完整的PHP程序如下
运友亮雹行结果
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)