Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/05/2010, 02:00
ddessimoni
 
Fecha de Ingreso: abril-2008
Mensajes: 2
Antigüedad: 16 años
Puntos: 0
Exclamación Problema Expresion regular PHP

Hola a todos


Estoy armando un funcion para reemplazar las url del youtbe y colocar el video atravez de un bbcode

para esto estoy usando una expresion regular pero en ocaciones no funcione como deberia,

la expresion es la siguiente

Código PHP:
$ret=eregi_replace("<a(.*)href=\"http:\/\/www\.youtube\.com\/watch\?v=([\w]{11})(.*)\"(.*)>(.*)</a>","[youtube]\\2[/youtube]",$ret); 

esto debe extraer el codigo de la url ( en rojo lo que resuelve)

<a id="video-long-title-2BbkWHWXeWA" href="http://www.youtube.com/watch?v=2BbkWHWXeWA" class="yt-uix-hovercard-target" title="TU ME DAS CREMITA YO TE DOY CREMITA....... ..." rel="nofollow"><b>TU ME DAS CREMITA</b> YO TE DOY <b>CREMITA</b>....... <b>...</b></a>

<a id="video-long-title-2BbkWHWXeWA" href="http://www.youtube.com/watch?v=Eklz3Q8HDiA" class="yt-uix-hovercard-target" title="TU ME DAS CREMITA YO TE DOY CREMITA....... ..." rel="nofollow"><b>TU ME DAS CREMITA</b> YO TE DOY <b>CREMITA</b>....... <b>...</b></a>

<a id="video-long-title-2BbkWHWXeWA" href="http://www.youtube.com/watch?v=FBJqvj4fL60" class="yt-uix-hovercard-target" title="TU ME DAS CREMITA YO TE DOY CREMITA....... ..." rel="nofollow"><b>TU ME DAS CREMITA</b> YO TE DOY <b>CREMITA</b>....... <b>...</b></a>


en estos caso es donde no funciona correctamente


<a id="video-long-title-ReqIkP9eOs0" href="http://www.youtube.com/watch?v=2XFEKRKJsgE&feature=related" class="yt-uix-hovercard-target" title="Tú me das cremita yo te doy..." rel="nofollow"><b>Tú me das cremita</b> yo te doy...</a>


<a id="video-long-title-dXxiC7ck5Io" href="http://www.youtube.com/watch?v=cS0O-o9qY9I&feature=related" class="yt-uix-hovercard-target" title="BUENAFUENTE 384 - Entrevista con Wyoming" rel="nofollow"><b>BUENAFUENTE</b> 384 - Entrevista con Wyoming</a>

y en estos casos no resuelve nada

desde ya muchas gracias