<tr> <td Height="30"> ·<a class="index_libiao" href="http://www.zh818.com/html/2014/033/7155319.aspx" title="3月14日上海钢材市场价格汇总" target="_blank"> <font color="#0000FF"> 3月14日上海钢材市场价格汇总</font> </a> </td> <td align="Right"> <span class="biaotiriqi"> 3月14日</span> </td> </tr> <tr> <td Height="30"> ·<a class="index_libiao" href="http://www.zh818.com/html/2014/033/7155318.aspx" title="3月14日北京钢材市场价格汇总" target="_blank"> <font color="#0000FF"> 3月14日北京钢材市场价格汇总</font> </a> </td> <td align="Right"> <span class="biaotiriqi"> 3月14日</span> </td> </tr> <tr> <td Height="30"> ·<a class="index_libiao" href="http://www.zh818.com/html/2014/033/7155317.aspx" title="3月14日天津钢材市场价格汇总" target="_blank"> <font color="#0000FF"> 3月14日天津钢材市场价格汇总</font> </a> </td> <td align="Right"> <span class="biaotiriqi"> 3月14日</span> </td> </tr> <tr> <td Height="30"> ·<a class="index_libiao" href="http://www.zh818.com/html/2014/033/7155316.aspx" title="3月14日重庆钢材市场价格汇总" target="_blank"> <font color="#0000FF"> 3月14日重庆钢材市场价格汇总</font> </a> </td> <td align="Right"> <span class="biaotiriqi"> 3月14日</span> </td> </tr> <tr> <td Height="30"> ·<a class="index_libiao" href="http://www.zh818.com/html/2014/033/7155315.aspx" title="3月14日广州钢材市场价格汇总" target="_blank"> <font color="#0000FF"> 3月14日广州钢材市场价格汇总</font> </a> </td>
我想获取所有<td Height="30">×××</td>的标签中间的内容,应该怎么写正则表达式呢
$pattern = "/<td Height=\"30\">([\s\S]*)<\/td>/"; preg_match_all($pattern, $str, $matches); var_dump($matches);
测试可以通过
$pattern = "/<td Height=\"30\">([\s\S]*)<\/td>/"; preg_match_all($pattern, $str, $matches); var_dump($matches);
测试可以通过
规则改下
$pattern = "/<td Height=\"30\">([\s\S]*?)<\/td>/"
preg_match_all("/<td\s+Height=\"30\">(.*)<\/td>/iUs", $str, $output);print_r($output);以上就是php正则表达式提取html标签的问题的内容,更多相关内容请关注PHP中文网(www.php.cn)!
立即学习“PHP免费学习笔记(深入)”;
相关文章:
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号