1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| /** this method replace one url in theText(param) by "URL"
*@param theText : the text to replace
*@return theText with the urls replaced by "URL"
*/
function replaceUrl($theText){
$expreg = "`"; // Début de ligne
$expreg .= "((http|news|ftp|https|irc)://)?"; // Le protocole et les "://", présent ou non
//inutile car www. est un sous-domaine comme les autres
$expreg .= "(www\.)?"; // Les 3 W, présent ou non
//ici il y avait une erreur a toi de chercher
$expreg .= "(([a-zA-Z0-9])*\.)+"; // Le domaine ou sous-domaine, alphanum, présent au moins une fois
$expreg .= "[a-zA-Z]{2,4}"; // l'extention, mini 2 et maxi 3 caractères
//ici pa obligé d'avoir de sous dossiers et une autre erreur
$expreg .= "(/([a-zA-Z0-9])*)?"; // les dossiers, sous dossier ou nom de fichier, alphanum, absent ou plusieurs
$expreg .= "(\.[a-zA-Z0-9]{2,4})?"; // l'extention de fichier, alphanum, présent ou non
$expreg .= "`"; // Fin de ligne
return preg_replace($expreg, "URL", $theText);
} |
Partager