Answer the question
In order to leave comments, you need to log in
How to regex cut content between tags given the dom structure?
There is this html code:
<div class="article">
<p class="title">Test!</p>
<div>Content content</div>
<p>test test</p>
<div class="test">test</div>
<p>test</p>
</div>
<?= rand(0,100); ?>
<div class="article">
<p class="title">Test1!</p>
<div>Content content1</div>
<p>test test1</p>
<div class="test">test1</div>
<p>test1</p>
</div>
/<div class="article">(.*?)<\/div>/igs
, but everything is killed on the first occurrence </div>
, you can set the U flag, but also not the same result :-( Answer the question
In order to leave comments, you need to log in
1. find all div.article: regex101.com/r/z6RRM7/1
2. remove tags "<[^>]*>" => ""
Most likely it's not the regular season, but the use of preg_match() instead of preg_match_all(). And yes, I can't resist posting this link .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question