Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/02/2010, 14:18
klarc
 
Fecha de Ingreso: febrero-2010
Mensajes: 6
Antigüedad: 14 años, 3 meses
Puntos: 0
Respuesta: Expreciones regulares php - ignorar tags

Bueno, no pude reproducir el error, es probable que puse algo mal yo, y también perdón por no dar mas dato, es que tengo la cabeza quemada.
Código PHP:
Ver original
  1. function UrlParser($texto)
  2.     {
  3.             $patron = "/(?<!\")((\s+(http[s]?:\/\/)|(www\.))?(([a-z][-a-z0-9]+\.)?[a-z][-a-z0-9]+\.(([a-zA-Z]{2}|aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel)(\.[a-z]{2,2})?))\/?[a-z0-9._\/~#&=;%+?-]+[a-z0-9\/#=?]{1,1})/is";
  4.            
  5.                 $str = uniqid('');
  6.                 $i=0;
  7.                 $codes = array();
  8.                 while (preg_match($patron, $texto, $matches) ) {
  9.                
  10.                     $i++;
  11.                     $link=  isset($matches[0])?$matches[0]:'';
  12.                      if(strrpos($link,'http://')=== false) $link= 'http://'. $link;
  13.                      $short_link = (strlen($link)>35)?self::tinyUrl($link):$link;
  14.                      $codes[$i]['link'] = ' <a rel="external nofollow" title="'.$link.'" href="'.$short_link.'">'.$short_link.'</a> ';     
  15.                     $texto = preg_replace($patron , $str.$i, $texto, 1);
  16.                 }  
  17.                 $i=0;
  18.                 while (preg_match("#".$str."([0-9]+)#", $texto, $matches))
  19.                 {
  20.                     $i++;    
  21.                     $texto = preg_replace("#".$str."([0-9]+)#", $codes[$i]['link'] , $texto, 1);
  22.                 }
  23.              return $texto;
  24.      }

gracias por la ayuda.