uguale ma con le preg
codice:
function html_activate_links2($str) {
  $str = preg_replace("/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_+.~#?&\/\/=]+)/", '\1', $str);
  $str = preg_replace("/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&\/\/=]+)/", '\1\2', $str);
  $str = preg_replace("/([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})/",'\1', $str);
  return $str;
}
//esempio
$stringa = "il mio sito è www.pippo.it e la mia mail è pippo@mail.it";
echo html_activate_links2($stringa);