正则匹配url

前端之家收集整理的这篇文章主要介绍了正则匹配url前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
preg_match_all | U | is 正则匹配url

$str= <<<EOF<div class="page-content clear" style="margin-top:5px" ><div class="chlsnav"> <div class="btt">zz列表</div> <a href="/a/DFMV"><div class="plst"><b>东方电影zz</b></div></a><div class="pbar"><b>zz</b></div><ul class="r" ><li><b>东方卫视</b><span></span></li><li><a href="/a/b-TOONMAX1-w4.html">炫动卡通卫视</a><span></span></li><li><a href="/a/b-b1-w4.html">新闻</a><span></span></li><li><a href="/a/b-b2-w4.html">第一财经</a><span></span></li><li><a href="/a/b-b3-w4.html">星尚</a><span></span></li><li><a href="/a/b-b4-w4.html">电视剧</a><span></span></li><li><a href="/a/b-b5-w4.html">体育</a><span></span></li><li><a href="/a/b-b6-w4.html">纪实</a><span></span></li><li><a href="/a/b-b7-w4.html">娱乐</a><span></span></li><li><a href="/a/b-b8-w4.html">艺术人文</a><span></span></li><li><a href="/a/b-b9-w4.html">外语</a><span></span></li><li><a href="/a/b-b10-w4.html">东方购物</a><span></span></li><li><a href="/a/b-b11-w4.html">哈哈少儿</a><span></span></li></ul><a href="/a/SHEDU"><div class="plst"><b>教育zz</b></div></a><a href='/a/SITV'><div class='plst'><b>SITVzz</b></div></a></div>EOF;$reg = '/<a(.*)href=[\"\'](.*)[\"\'][^>]*><div class=\"plst\"><b>(.*)<\/b><\/div><\/a>/U';$reg = '/<a[^href]*href=[\"\']([^\"|\']*)[\"\'][^>]*><div class=[\"\']plst[\"\']><b>(.*?)<\/b><\/div><\/a>/is';//$reg = '/<a[^href]*href="([^"]+)"[^>]*><div class=\"plst\"><b>(.*?)<\/b><\/div><\/a>/is';//$reg = "|<a href=\"([^>]+)\"><div class=\"plst\"><b>(.*?)</b></div></a>|is";preg_match_all($reg,$str,$match);print_r($match);//preg_match('/.+(<a.+?class="plst".+?a>)/is',$match);//$reg = "/<a(.*)href=[\"\'](.*)[\"\']><div class=\"plst\"><b>(.*)<\/b><\/div><\/a>/isU";//$reg = "|<a href=\"([^>]+)\"><div class=\"plst\"><b>(.*?)</b></div></a>|U";exit;

猜你在找的正则表达式相关文章