$re = '/<a\s+href="https?:\/\/?(?:www\.)?((?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,8})(?:"|\/).*?>(?:https?:\/\/)?(?:www\.)?\1/im';
$str = '<span style="color:rgb(128,0,0);font-weight:bold">> Оформлен заказ в магазине <a href="http://www.test1.com" target="_blank">test1.com</a> </spant-family:arial,sans-serif>
<a href="http://test.site.com/11222/sdf.html">http://www.test.site.com</a><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px">SOME MESSAGE TEXT</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"><a href="http://www.test2.com/">www.test2.com/123/test</a>
SOME TEXT</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"><a href="http://www.TEsst.com/">https://tesst.com</a><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"> === =size:12.8px"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px"><a href="http://site.org">site.org</a>
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php