Inspired by Akarun's answer I came up with tis function to handle all protocols and links that start with only www.
function make_links($text, $class='', $target='_blank'){
return preg_replace('!((http\:\/\/|ftp\:\/\/|https\:\/\/)|www\.)([-a-zA-Zа-яА-Я0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?!ism',
'$1$3',
$text);
}
This function has optional parameters to add class names onto the links and also optional target for the link, so they open on new window/tab... by default the parameter opens links to new window/tab, but if you feel like not doing that, you can change default, or change the value when calling the function.