Reputation: 21627
$str = '<div class="rss"><img src="http://www.wired.com/images_blogs/gadgetlab/2013/10/1125_hbogo_660-660x436.jpg" alt="You Can Now Get HBO GO Without Paying for Other Channels">
</div>Fans of';
I'm trying to get hold of the text after the <div class="rss"></div>
but each expression I use doesn't seem to work.
matching .rss
if(preg_match('/^(<div class=\"rss\">[\S\s]+?</div>([\S\s]*)$/i', $item_content, $matches)) {
Could someone please help with this expression?
Originally I had this expression to match an image tag instead of a div and this worked fine by using
if(preg_match('/^(<img[\S\s]+?>)([\S\s]*)$/i', $item_content, $matches)) {
Upvotes: 0
Views: 2400
Reputation: 8741
This may help:
<?php
$item_content = '<div class="rss"><img src="http://www.wired.com/images_blogs/gadgetlab/2013/10/1125_hbogo_660-660x436.jpg" alt="You Can Now Get HBO GO Without Paying for Other Channels">
</div>Fans of';
if(preg_match('/^(<div class=\"rss\">[\S\s]+?<\/div>)([\S\s]*)$/i', $item_content, $matches)) {
$div = $matches[1];
$text = $matches[2];
echo "<textarea style=\"width: 600px; height: 300px;\">";
echo $div . "\n";
echo $text . "\n";
echo "</textarea>";
}
?>
Upvotes: 0