Try parsing the HTML using DOMDocument() instead of regex.
However, here is the regex to parse assuming there will be no nested div
:
$html= 'Example: Lorem <div class=ab>1 2</div>ipsum <div class=ab>3 4</div>dolor.';
preg_match_all('|<div class=ab>([^<]*)</div>|i', $html, $m);
print_r($m[1]);
And for parsing the title id:
$html = 'http://www.imdb.com/title/tt29747">';
preg_match('|imdb.com/title/(tt\d+)|i', $html, $m);
print_r($m[1]);