Petit nouveau ! |
3 Messages
29 mars 2012, 17:10
Malgré tes conseils, je galère encore.
J'ai essayé cela :
<?php
$texte='Bonjour J ai eu la chance de participer a la randoween cette annee et en ai redige un compte-rendu sur mon blog.http://running.sebrom.org/2011/12/randoween-2011.html Merci encore pour cette manifestation sympathique et agreable! Sportivement Sebastien' ;
$brute = array();
$brute[0] = '/http/';
$brute[1] = '/.html/';
$brute[2] = '/.php/';
$replacements = array();
$replacements[0] = '<a href="http';
$replacements[1] = '.html">';
$replacements[2] = '.php">';
echo preg_replace($brute, $replacements, $texte);
cela marcherait, mais je n'arrive pas à copier le lien.
j'ai trouvé aussi ça, mais je n'arrive pas à le mettre en forme :
<?php
string orig = 'Bonjour J ai eu la chance de participer a la randoween cette annee et en ai redige un compte-rendu sur mon blog.http://running.sebrom.org/2011/12/randoween-2011.html Merci encore pour cette manifestation sympathique et agreable! Sportivement Sebastien' ;
string debut='http';
string fin='html';
public string RemplaceChaineEntre(string orig, string debut, string fin, string remplacement) {
string pattern = string.Format("({0})(.*)({1})", debut, fin);
Regex regex = new Regex(pattern, RegexOptions.Singleline);
return regex.Replace(orig, "$1" + remplacement + "$3");
}
function linker($url)
{ return '<a href="'.$url.'">'.$url.'</a>';
}