I'm trying to strip one particular div (and it's inner contents) out of a block of content, however it isn't quite working.
Regex:
/<div class="greybackground_desktop".*>(.*)<\/div>/s
Preg_replace:
preg_replace($pattern, "", $holder, -1, $count );
Now, the regex does indeed strip out my div, however if there are any other following closing div tags, it'll strip them out too and any other content inside it.
e.g.
<p>some random text</p>
<div class="greybackground_desktop" style="background-color:#EFEFEF;">
<!-- /49527960/CSF_Article_Middle -->
<div style="padding-bottom:10px; padding-top: 10px; text-align:center;" id='div-gpt-ad-1441883689230-0'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1441883689230-0'); });
</script>
</div>
</div>
<p>some more text</p>
<div><p>example of content that will be incorrectly removed</p></div>
<p>Text that follows</p>
This will result in the following output:
some random text
Text that follows
What I am wanting to see is:
some random text
some more text
example of content that will be incorrectly removed
Text that follows
Any ideas?