PHP-kod:
function strLinks($text) {
$text = preg_replace('%(<a\s[^>]+>http://[^\s]+</a>)|(<[^>]+http://[^>]+>)|(http://)[^\s]+%ie',
'"$0"=="$1" || "$0"=="$2" ? "$0" : "<a target=\"_blank\" href=\"$0\">$0</a>"', $text);
$text = preg_replace("/([w.-_]+)(@)([w.-_]+)(\.)([w.-_]+)/i", "<a href=\"mailto:$0\">$0</a>",$text);
$text = preg_replace('%(<a\s[^>]+>http://|www.[^\s]+</a>)|(<[^>]+www.[^>]+>)|(www.)[^\s]+%ie',
'"$0"=="$1" || "$0"=="$2" ? "$0" : "<a target=\"_blank\" href=\"http://$0\">$0</a>"', $text);
return $text;
}