So I'm working on a regexp to catch all links in a string, meaning wordsthat start with with a protocol like http, https etc, words that start with www. or words that end in some specific domains, ".com", ".hr" and ".net". But somehow this regexp I made always returns all the links that start with a protocol, but only the last one of those that end in a specific domain. What am I doing wrong :|? Many thanks!
$description='test.com test2.hr http://www.test3.hr https://test4.com test3.net';
$pattern = '/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]|(?:\b((?:[\w]+\.com$)|(?:[\w]+\.hr$)|(?:[\w]+\.net$)))/i';
preg_match_all($pattern, $description, $out);
var_dump($out[0]);