First off: I think your keyboard is broken, because half of the words come out distorted (You are not on your cellphone)
Second: Try this, I wrote it a loonong time ago, pretty sure there are more efficient ways to do it now, but it should work:
$string = preg_replace("#(|[\n ])([\w]+?://.?[^ \"\n\r\t<])#is", "\1<a href=\"\2\">\2</a>", $string);