Question: I want to parse a html content that have something like this:

```
<div id="sometext">Lorem<br> <b>Ipsun</b></div><span>content</span><div id="block">lorem2</div>

```

I need to catch just the "`Lorem<br> <b>Ipsun</b>`" inside the first div. How can I achieve this? 

> 
> Ps: the html inside the first div have
>  multiple lines, its an article.
> 
> 
> 

Thanks

Answer: 
Trying to [use regex to parse HTML](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) is not a very nice experience as HTML isn't a regular language. An alternative would be to use a HTML parser like [Simple HTML DOM](http://simplehtmldom.sourceforge.net/) or the [DOM](http://php.net/manual/en/book.dom.php) library/

Simple HTML DOM Example:

```
$html = str_get_html('<div id="sometext">Lorem<br> <b>Ipsun</b></div><span>content</span><div id="block">lorem2</div>');
echo $html->find('div[id=sometext]', 0)->innertext;

```
Assuming that the `id` is known:

```
preg_match('#<div id="sometext">(.*?)</div>#s', $text, $match);

```