regex php: find everything in div
Posted
by Fifth-Edition
on Stack Overflow
See other posts from Stack Overflow
or by Fifth-Edition
Published on 2009-08-29T18:36:12Z
Indexed on
2010/03/31
7:23 UTC
Read the original article
Hit count: 362
I'm trying to find eveything inside a div using regexp. I'm aware that there probably is a smarter way to do this - but I've chosen regexp.
so currently my regexp pattern looks like this:
$gallery_pattern = '/([\s\S]*)<\/div>/';
And it does the trick - somewhat.
the problem is if i have two divs after each other - like this.
<div class="gallery">text to extract here</div>
<div class="gallery">text to extract from here as well</div>
I want to extract the information from both divs, but my problem, when testing, is that im not getting the text in between as a result but instead:
"text to extract here
text to extract from here as well"
So . to sum up. It skips the first end of the div. and continues on to the next. The text inside the div can contain "<", "/" and linebreaks. just so you know!
Does anyone have a simple solution to this problem? Im still a regexp novice.
© Stack Overflow or respective owner