Heim > Artikel > Backend-Entwicklung > 请教这个用正则怎么匹配
请问这个用正则如何匹配?
目的是匹配网页源代码中的href,大概有三种类型
类型一:
$str= <a href="http://bbs.111.com/thread-11.html" onclick="atarget(this)" class="xst">一一一一(seo)</a> 类型二: <th class="common"> <em>[<a href="http://www.444.com/forum.php?">引蜘蛛</a>]</em><a href="http://www.444.com/thread-263.html" onclick="atarget(this)" class="xst">二二二二</a> 类型三: </th><th class="common"> <a href="http://www.555.com/thread-161.html" style="color: #EC1282" class="xst" target="_blank">三三三</a> </th><th class="aa"> <a href="http://www.555.com/thread-161.html" style="color: #EC1282" class="xst" target="_blank">三三三</a> html; preg_match_all('/(?:</th><th class="new|common">).+<a href="(%5B%5E" print_r class="clear"> </a> </th>