求一个正则,规则如下说明:对于html代码中的超链接进行筛选,把href中的扩展名为.rar的选出来,比如有一段html为
$str="出生于上海,毕业于上海。<a href='http://www.baidu.com/abc.rar'>11111</a>出生于h,毕业于f,<a href='http://www.doc.com/abc.doc'>2222</a>ttttt<a href='http://www.g.com/g.rar'>33333</a>";
应该筛选出<a href='http://www.baidu.com/abc.rar'>11111</a>和<a href='http://www.g.com/g.rar'>33333</a>。请赐教这个正则该怎么写呢?
$str="出生于上海,毕业于上海。<a href='http://www.baidu.com/abc.rar'>11111</a>出生于h,毕业于f,<a href='http://www.doc.com/abc.doc'>2222</a>ttttt<a href='http://www.g.com/g.rar'>33333</a>";
应该筛选出<a href='http://www.baidu.com/abc.rar'>11111</a>和<a href='http://www.g.com/g.rar'>33333</a>。请赐教这个正则该怎么写呢?
$str="出生于上海,毕业于上海。<a href='http://www.baidu.com/abc.rar'>11111</a>出生于h,毕业于f,<a href='http://www.doc.com/abc.doc'>2222</a>ttttt<a href='http://www.g.com/g.rar'>33333</a>";
preg_match_all('/<a href=\'([^>]*\.rar)\'>/is', $str, $matches);
print_r($matches[1]);
?>
$str="出生于上海,毕业于上海。<a href='http://www.baidu.com/abc.rar'>11111</a>出生于h,毕业于f,<a href='http://www.doc.com/abc.doc'>2222</a>ttttt<a href='http://www.g.com/g.rar'>33333</a>";
preg_match_all('/<a href=\'[^>]*\.rar\'>(.*)<\/a>/is', $str, $matches);
print_r($matches[1]);
?>