Convert Input links in a forum to URLS
<?php
$text = "Check the web site, http://www.oreilly.co.in/hmv/
. Really kool";
$regex =
"{ \\b # start at word\n"
. " # boundary\n"
. "( # capture to $1\n"
. "(https?|telnet|gopher|file|wais|ftp) : \n"
. " # resource and colon\n"
. "[\\w/\\#~:.?+=&%@!\\-]+? # one or more valid\n"
. " # characters\n"
. " # but take as little as\n"
. " # possible\n"
. ")\n"
. "(?= # lookahead\n"
. "[.:?\\-]* # for possible punct\n"
. "(?:[^\\w/\\#~:.?+=&%@!\\-] # invalid character\n"
. "|$) # or end of string\n"
. ") }x";
echo preg_replace($regex, "<a href=\"$1\">$1</a>", $text);
?>
OUTPUT
Check the web site, http://www.oreilly.co.in/hmv/ . Really kool