I want to extract content from a div whose id starts with a specific string, but ends with anything. Example:
I have a div
<div id="content_message_56384">
My first post.
</div>
My code:
$regex = '#\<div id="content_message_[*]"\>(.+?)\<\/div\>#s';
preg_match($regex, $intro, $matches);
echo $match = $matches[0];
But I'm not not getting any result. Please help.
The code should be this:
Please, note that I'm using a non-capturing expression here
(?:\d+)
because you only need what's inside the<div>
.