PHP正则表达式:提取img标签的标题

I'm trying to learn reg exp,

i want to get title of <img only from the text

the text is differ and basically look like this

<a href="http://abcde.com" target="_blank"><img src="http://abcde.com/img/aa.jpg" title="img title" id="img id" class="img class" />

any guidance and advise are appreciated..

look in this so answer:

How to extract img src, title and alt from html using php?

a lot of good answers !

it would be something like that:

'|<img(.*)title="(.*)"(.*)/>|Um'

but i would advise to parse html through dom (DomDocument, simplehtmldom, etc):

$doc = new DomDocument();
$doc->loadHTML($page);
$imgElement = $doc->getElementById('img id');
$title = $imgElement->getAttribute('title');

You'll get the answer "Don't use regular expressions!" But if you still want to, try:

#<img[^>]+title="([^"]*)"#

PS: This regex assumes that there is no > in any attribute before title. If this may not be assumed, say so.