I go cross-eyed when it comes to reading this stuff. I hacked some code I found, catches "bit.ly" but not (for example) "ff.im"
(Can I post code here?) function urls2link($text){ if (strpos($text, '...')==0) { // don't ask! $pattern = '\b((((H|h)(T|t)(T|t)(P|p))\://)?(www.|[a-zA-Z0-9]{1,99}.) [a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}'; $pattern .= '(\:[0-9]{1,5})*(/(|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-] +?))*)($|[^\w/][<\s]|[<\s]|[^\w/]$)'; $replacement = '\'<a target="_new" href="\'.((\'$4\' == \'\')? \'http://$1\':\'$1\').\'" >$1</a> $16\''; return preg_replace('¦'.$pattern.'¦e', $replacement, $text); } else return $text; }; Works most of the time, but clearly has issues. I figure somebody has already solved this and wants to share ;-)