As the regular season to cut the content between the tags given the structure of the dom?

There's a html code:
<div class="article">
 <p class="title">Test!</p>
 the <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>
 the <div>Content content1</div>
 <p>test test1</p>
 <div class="test">test1</div>
<p>test1</p>
</div>


Prompt, please, the regular season, which would choose the content within the div tags.article.

Try /
(.*?)<\/div>/igs, but all zerobeta on the first occurrence
you can put a flag U, but also the wrong result :-(
I want to do it with regexps, not by the xml parser

Here is the link to the sandbox https://regex101.com/r/6HDlxK/1/

Thank you!
June 14th 19 at 18:19
3 answers
June 14th 19 at 18:21
Solution
1. find all div.article: regex101.com/r/z6RRM7/1
2. remove tags "<[^>]*>" => ""
Still, for such tasks it is better to use `DOMDocument` or `SimpleXML`.
Should the structure change, for example
<div class="article"><div>Content content</div></div>

would not have to work

PS: No famous answer on SO this review would not be complete: https://stackoverflow.com/a/1732454 - Candace_Bogisich commented on June 14th 19 at 18:24
all this is true, but I realized how stupid the desired text. - iliana_Monah commented on June 14th 19 at 18:27
the same DOMDocument maybe just the content string to display - Candace_Bogisich commented on June 14th 19 at 18:30
although Yes. I agree. - iliana_Monah commented on June 14th 19 at 18:33
June 14th 19 at 18:23
It is not likely in the regular season, and to use preg_match() instead of preg_match_all(). And Yes, I can not resist not to post this link.
June 14th 19 at 18:25
In mind this is a SAX parser, not regular season.

Find more questions by tags Web DevelopmentRegular expressionsProgrammingPHP