I use PHP pattern modifier "U" to invert the default greedy behavior with preg_match(). However, it doesn't work the way I want. My code:
$str = '<p>
<div><a aaa
<a href="a.mov"></a>
</div>
</p>';
$needle = "a.mov";
$pattern = "/\<a.*".preg_quote($needle, "/").".*\<\/a\>/sU";
preg_match($pattern, $str, $matches);
print_r($matches);
I'm trying to match on
<a href="a.mov"></a>
But this chunk of code returns me
<a aaa
<a href="a.mov"></a>
Can someone shed me some light of where I did wrong?