各位大牛,求教个正则表达式怎么写。抓取网页中的一段内容:
<code><div class="location fl">
<span class="fl">商家地址:</span><span class="fl info-detail">北京市朝阳区亚运村阳光广场北门对面</span>
</div></code>我的写的正则是:
<code>"<div class=\"location fl\">\s*?<span class=\"fl\">.*?</span><span class=\"fl info - detail\">(.*?)</span>\s*?</div>"</code>
在正则表达式测试器上能通过,但是在php上跑不出结果。应该怎样修改呢?
各位大牛,求教个正则表达式怎么写。抓取网页中的一段内容:
<code><div class="location fl">
<span class="fl">商家地址:</span><span class="fl info-detail">北京市朝阳区亚运村阳光广场北门对面</span>
</div></code>我的写的正则是:
<code>"<div class=\"location fl\">\s*?<span class=\"fl\">.*?</span><span class=\"fl info - detail\">(.*?)</span>\s*?</div>"</code>
在正则表达式测试器上能通过,但是在php上跑不出结果。应该怎样修改呢?
使用xpath,可以解决。"//div//span[contains(@class,'info-detail')]/text()[1]"
继续求正则表达式该怎样写。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号