Можно ли использовать не жадное регулярное выражение с dotall?

Я хотел бы сопоставить dotall и non-greedy. Вот что у меня есть:

img(.*?)(onmouseover)+?(.*?)a

Однако это не является не-жадным. Эти данные не совпадают, как я ожидал:

<img src="icon_siteItem.gif" alt="siteItem" title="A version of this resource is available on siteItem" border="0"></a><br><br></td><td rowspan="4" width="20"></td></tr><tr><td>An activity in which students find other more specific adjectives to 
describe a range of nouns, followed by writing a postcard to describe a 
nice holiday without using the word 'nice'.</td></tr><tr><td>From the resource collection: <a href="http://www.siteItem.co.uk/index.asp?CurrMenu=searchresults&amp;tag=326" title="Resources to help work">Drafting </a></td></tr><tr><td><abbr style="border-bottom:0px" title="Key Stage 3">thing</abbr> | <abbr style="border-bottom:0px" title="Key Stage 4">hello</abbr> | <abbr style="border-bottom:0px" title="Resources">Skills</abbr></td></tr></tbody></table></div></div></td></tr><tr><td><div style="padding-left: 30px"><div><table style="" bgcolor="#DFE7EE" border="0" cellpadding="0" cellspacing="5" width="100%"><tbody><tr valign="top"><td rowspan="4" width="60"><a href="javascript:requiresLevel0(350,350);"><img name="/attachments/3700.pdf" onmouseover="ChangeImageOnRollover(this,'/application/files/images/attach_icons/rollover_pdf.gif')" onmouseout="ChangeImageOnRollover(this,'/application/files/images/attach_icons/small_pdf.gif')" src="small_pdf.gif" alt="Download Recognising and avoiding ambiguity in PDF format" title="Download in PDF format" style="vertical-align: middle;" border="0"></a><br>790.0 k<br>

и я не могу понять почему.

Я думаю, что я заявляю в приведенном выше регулярном выражении:

начинаются с «img», затем разрешаются 0 или более любых символов, включая новая строка, затем найдите хотя бы 1 «onmouseover», затем разрешите 0 или более любых символов, включая новую строку, затем «a»

Почему это не работает так, как я ожидал?

КЛЮЧЕВОЙ МОМЕНТ: dotall должен быть включено

8
задан Martin Thoma 12 October 2015 в 16:43
поделиться