Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/10/2011, 19:47
edward18_1
 
Fecha de Ingreso: septiembre-2011
Mensajes: 480
Antigüedad: 12 años, 7 meses
Puntos: 18
Respuesta: Expresiones regulares

ya consegui como :D la verdad busque por una pagina en internet...porque para ser sincero de expresiones regulares no se nada...no se porq pero es que no las entiendo..por eso es que pido aqui ayuda ps entonces

obtuve esto
Código PHP:
Ver original
  1. function texto_a_url($text){
  2.         // pad it with a space so we can match things at the start of the 1st line.
  3.         $ret = ' ' . $text;
  4.  
  5.         // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
  6.         // xxxx can only be alpha characters.
  7.         // yyyy is anything up to the first space, newline, comma, double quote or <
  8.         $ret = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</a>', $ret);
  9.  
  10.         // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
  11.         // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
  12.         // zzzz is optional.. will contain everything up to the first space, newline,
  13.         // comma, double quote or <.
  14.         $ret = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $ret);
  15.  
  16.         // matches an email@domain type address at the start of a line, or after a space.
  17.         // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
  18.         $ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
  19.  
  20.         // Remove our padding..
  21.         $ret = substr($ret, 1);
  22.  
  23.         return($ret);
  24.     }

como se deberia modificar para obtener lo que yo quiero principalmente? gracias