$re = '~(?<!http://)(?<!https://)(?<!www\.)(?![^\s<>]*[:@/])(?<![(=:] )(?<!\(")(?:(?<=[\s">])|^)(?:[a-z0-9-]+\.){2}(?!info|biz|tv)[a-z]+(?=[\s"<]|$)(?! [=):])(?!"\))~m';
$str = 'sub84.example4.com
sub-example.example84.net
sub-84example.example-h1.org
www-example4124.domain.com
sub.example-www.com
text = sub1.example.com text
text ( sub2.example.com text
text sub3.example.com = text
text sub4.example.com ) text
text ("sub5.example.com text
text sub6.example.com") text
text : sub7.example.com text
text sub8.example.com : text
http://www.example1.com text
<p>sub84.example4.com</p>
text.. http://sub2.example2.com
<span>sub-example.example84.net</span>
<a href="sub-84example.example-h1.org"> text
text www-example4124.domain.com
text www.example564.adam.com
text http://example484.com text
text name@sub.example484.com text
https://example48484.com
sub.example-www.com text
sub-111example.example-h1.org/page.php
sub84.example4.com
sub-example.example84.net
sub-84example.example-h1.org
www-example4124.domain.com
sub.example-www.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