Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
841 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  regexp pour une url

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

regexp pour une url

n°797389
Profil sup​primé
Posté le 16-07-2004 à 11:00:04  answer
 

bordel ya rien a faire, j'arrive pas a choper une url dans un texte et le transformer en lien :cry:
 
j'ai fait
 

$string="http://www.hardware.fr";
 
function links($link) {
 $link= preg_replace("/http:\/\/(.+?)/si", "<a href=\"http://$1\">http://$1</a>", $link);  
 return $link;
}
 
echo links($string);

soit tres, tres, tres basique
 
il ne creer un lien que sur le http://w, et le lien mene vers http://w/ :D
 
bref, je comprend pas :/


Message édité par Profil supprimé le 16-07-2004 à 11:01:55
mood
Publicité
Posté le 16-07-2004 à 11:00:04  profilanswer
 

n°797395
jagstang
Pa Capona ಠ_ಠ
Posté le 16-07-2004 à 11:06:23  profilanswer
 

y'a ça ici : http://forum.hardware.fr/hardwaref [...] 2268-1.htm


---------------
What if I were smiling and running into your arms? Would you see then what I see now?  
n°797396
simogeo
j'ai jamais tué de chats, ...
Posté le 16-07-2004 à 11:07:13  profilanswer
 

chacal > si tu veux moi j'avais choppé une regex merdique pour faire ca ... je l'ai blindé pour qu'elle intégre plusieurs protocoles, les url a rallonge et meme les ftp avec user et pass [:franck75]
( elle reste a mon avis assez merdique - je ne l'ai pas bcp testée, mais elle est assez polyvalente)  
 
tu la veux ?


---------------
from here and there -- \o__________________________________ -- la révolution de la terre, en silence
n°797409
Profil sup​primé
Posté le 16-07-2004 à 11:13:54  answer
 

pas trouvé jag :/
 
simo : ouais [:dawacube]

n°797416
jagstang
Pa Capona ಠ_ಠ
Posté le 16-07-2004 à 11:16:17  profilanswer
 

pardon c'était là :  
 
http://forum.hardware.fr/hardwaref [...] tm#t114432


---------------
What if I were smiling and running into your arms? Would you see then what I see now?  
n°797421
Profil sup​primé
Posté le 16-07-2004 à 11:18:31  answer
 

parfait merci :)

n°797473
simogeo
j'ai jamais tué de chats, ...
Posté le 16-07-2004 à 11:39:09  profilanswer
 

Code :
  1. $content = eregi_replace("(http|https|ftp|ftps)://([-a-z0-9#?/&=:,_;@%.{}]*)([a-z0-9=]{2,4})", '<a href="\\1://\\2\\3">\\1://\\2\\3</a>', $content);


 
[:itm]


---------------
from here and there -- \o__________________________________ -- la révolution de la terre, en silence
n°797474
Profil sup​primé
Posté le 16-07-2004 à 11:40:37  answer
 

question :o
 
pourquoi des fois c'est $1,2 3... et des fois \\1, \\2 3 ... ??

n°797482
simogeo
j'ai jamais tué de chats, ...
Posté le 16-07-2004 à 11:42:43  profilanswer
 

chacal_one333 a écrit :

question :o
 
pourquoi des fois c'est $1,2 3... et des fois \\1, \\2 3 ... ??


 
 
réponses [:itm]
 
 $1,2 3... : avec preg
 
\\1, \\2 3  : avec ereg


---------------
from here and there -- \o__________________________________ -- la révolution de la terre, en silence
n°797488
Profil sup​primé
Posté le 16-07-2004 à 11:44:45  answer
 

ah ok, tout con :)
 
merci

mood
Publicité
Posté le 16-07-2004 à 11:44:45  profilanswer
 

n°797492
simogeo
j'ai jamais tué de chats, ...
Posté le 16-07-2004 à 11:46:13  profilanswer
 

chacal_one333 a écrit :

ah ok, tout con :)
 
merci


 
heeee ooo   :o , j'temmerde moi heinnn  :o  
 
 
[:itm]


---------------
from here and there -- \o__________________________________ -- la révolution de la terre, en silence

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  regexp pour une url

 

Sujets relatifs
[REGEXP PERL] Autoriser les apostrophes.une regexp me bloque
[résolu] Regexp ( IP:port )[Perl] Besoin d'un ti coup de pouce pour une regexp
[RegExp]Exclure les points[Java] Regexp pour sortir un chemin sans le nom de fichier
[Regexp]Exclure une chaine d'une expressionRegExp
[Regexp] Supprimer tous les espaces,\t,\n\r en dehors des balisesEncore du Regexp
Plus de sujets relatifs à : regexp pour une url


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR