Hello everyone,
I have a small problem for using a regex in PHP. The problem is that I get a text output from another website. I want to get some informations by using a regex but I'm not sure in advance how the informations will be display.
Here the example:
Text Output
<br/><b>Description:</b><br/>This is a good description<br/><b>Title:</b><br/>MY TITLE<br/><b>Comment:</b><br/>Very interesting<br />...
I would like to get only the content of Description (without the label too) but I'm not sure that all the other label will be there and in this way, so it could be only title or only comment or any of them.
The only way I found is if I am sure both of them are present and fix:
$pattern = '#<b>Description</b><br/>(.+)<br/><b>Title</b><br/>(.+)<br/><b>Comment</b><br/>(.+)#';
if (preg_match($pattern, $description, $match)) {
$description = $match[1]; // Text description
}
How can I do?
Thank you.