简体   繁体   中英

Getting DIV content with Regular Expression

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

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

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

Thanks in advance...

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.*>).*?(?=</div>)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM