Mega Code Archive
Replacing URLs with Links
#\"\s]+)?";
$queryRegex = "(\?[^<>#\"\s]+)?";
$urlRegex = "/(?:(?<=^)|(?<=\s))((ht|f)tps?:\/\/" . $hostRegex . $portRegex . $pathRegex . $queryRegex . ")/";
$str = "http://home.example.com.";
$str2 = "http://home.example.com:8181/index.php";
echo $urlRegex . "\n";
$sample1 = preg_replace($urlRegex, "\\1", $str);
$sample2 = preg_replace($urlRegex, "\\1", $str2);
echo $sample1 . "\n";
echo $sample2 . "\n";
?