There is question by the almost the same name already: What is the best regular expression to check if a string is a valid URL
I don\'t understand this stackoverflow
Thanks ircmaxell but I had to adjust a little the IPV6 regex for PHP to compile with preg_match.
I changed:
$ipv6 = "([({$rawIpv6}|{$ipv4sub})])";
To :
$ipv6 = "({$rawIpv6}|{$ipv4sub})";