If you have in one big string:
<?php
$str = '<a href="ABC.jpg">Hello</a> <a href="DEF.jpg">Bye</a>';
$expr = '/<a[^>]*? href=\"(?<url>[^\"]+)\"[^>]*?>(?<text>.*?)<\/a>/';
echo preg_match_all($expr, $str, $amatches);
echo '<br><br>';
print_r($amatches);
?>
You can also use:
preg_match_all($expr, $str, $amatches, PREG_SET_ORDER);
Which may suit better (I ofen prefer this approach)
If you have in spearate strings and handle in a loop, use preg_match instead. Tis will only return the first, and you loop.
Edit: here it is with your example, as requested.
<?php
$str = '<a onmouseover="dgsa.sm(this)" onmouseout="dgsa.hm();" href="http://www.cnn.com/testpage.html#page_mostview">test titles</a>';
$expr = '/<a[^>]*? href=\"(?<url>[^\"]+)\"[^>]*?>(?<text>.*?)<\/a>/';
echo preg_match_all($expr, $str, $amatches, PREG_OFFSET_CAPTURE);
echo '<br><br>';
print_r($amatches);
?>