$re = '/(((?:")(https?:\/\/)(?!example123\.com)[^"]+(?:"))|((https?:\/\/)(?!example123\.com)[^\s"]+))/m';
$str = 'http://domain.com/
domain.com
<a href="http://domain.com/article/%D0%90%D0%BD%D1">...</a>
<a href="http://domain.com/article/">...</a>
<a href="http://domain.com/article/">...</a>
<img href="http://domain.com/article/Кошка Собака.png">
<link href="http://domain.com/">
<area href="http://domain.com/">
<base href="http://domain.com/">
http://example123.com
example123.com
<a href="http://example123.com/article/%D0%90%D0%BD%D1">...</a>
<a href="http://example123.com/article/">...</a>
<a href="http://example123.com/article/">...</a>
<img href="http://example123.com/article/Кошка Собака.png">
<link href="http://example123.com/">
<area href="http://example123.com/">
<base href="http://example123.com/">';
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