Update:
I'm using this regex:
/[^a-z^-^0-9^@^%^\/^:^\.^-]((?<!w\.)(?!w+\.)([0-9a-z][0-9a-z\-]*\.){2,}[a-z]+)(["|\s|<]|$)/i
The regex have a little problem when the string is only domains and nothing else, listed under each other in new lines
For example:
$string = 'sub84.example4.com
sub-example.example84.net
sub-84example.example-h1.org
www-example4124.domain.com
sub.example-www.com';
All domains should be matched, but he current regex is only match sub-example.example84.net
and www-example4124.domain.com
I also looking to add some more conditions:
1) letters of domain must be small and can't be capital (the current one doesn't care about that)
EX: Sub.example.Com
is not ok.
2) No =SPACE
(SPACE
("
:SPACE
before the domain and NO SPACE)
or SPACE=
")
SPACE:
after it.
EX:
$string = '
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
';
None of them is ok
3) Exclude .info
.biz
.tv
tlds
Thank you.