使用正则表达式获取 DIV 内容 [英] Getting DIV content with Regular Expression

查看:51
本文介绍了使用正则表达式获取 DIV 内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用正则表达式获取 DIV 的内容.我需要得到的是介于两者之间;

How can I get content of a DIV using regular expression. What I need to get is in between;

<div class="lv1right dfbg">......</div>

在这些 div 标签之间还有几个(没有明确定义的)标签,我想得到所有这些..

Also there are several (not well defined) tags between these div tags, and I would like to get all of them..

提前致谢...

推荐答案

我会避免对 HTML 使用正则表达式,因为 HTML 不是常规的.而是查看 这个 PHP DOM 解析器,它可以让您更可靠地提取/更改 HTML.

I'd avoid using regexps for HTML, since HTML isn't regular. Instead check out this PHP DOM parser, which will allow you to extract/change the HTML much more reliably.

这篇关于使用正则表达式获取 DIV 内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆