function twitify($str) { $str = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1\\2", $str); $str = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1\\2", $str); $str = preg_replace("/@(\w+)/", "@\\1", $str); $str = preg_replace("/#(\w+)/", "#\\1", $str); return $str; }