she hates me
she hates me

Reputation: 1272

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...

Upvotes: 0

Views: 1395

Answers (2)

xoxo
xoxo

Reputation: 577

(?<=<div.*>).*?(?=</div>)

Upvotes: 0

Brian Agnew
Brian Agnew

Reputation: 272237

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.

Upvotes: 6

Related Questions