//Transform URL and e-mails into links
$texte = eregi_replace(
"(^|[ \t\r\n\(:,]+)?". //punctuation before URL
//Protocole
"((ftp|http|https|gopher|mailto|pop|smtp|news|nntp|telnet|wais|".
"file|imap|prospero|peercast|ed2k|irc|aim|mime|ftam|pnm|rtsp|ldap):".
"[A-Za-z0-9/](([A-Za-z0-9$|.+!*()\.,;/?:@&~=_-])|%[A-Fa-f0-9]{2})+".
"[A-Za-z0-9/&#=_-]+)". //valid chars at the end of an URL
"([\.\),:;? \t\r\n]+([^A-Za-z0-9/&%#=_-]|$))?", //punctuation not followed by valid char
"\\1<a href='\\2' target=\"blank\">\\2</a>\\6", $texte);
$texte = eregi_replace("(^|[ \t\r\n\(,<>:]+)?".
"([_a-z0-9-]+[^:/=](\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+(\?[&;A-Za-z0-9=_-]+)?)".
"([\.\),:;<>? \t\r\n]+([^A-Za-z0-9/&%#=_-]|$))?",
"\\1<a href=\"mailto:\\2\">\\2</a>\\6", $texte);
Partager