Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/03/2012, 03:20
Avatar de ZiTAL
ZiTAL
 
Fecha de Ingreso: marzo-2004
Ubicación: Bermio (Bizkaia)
Mensajes: 1.545
Antigüedad: 20 años, 1 mes
Puntos: 62
Respuesta: expresiones regulares extraer link

Código PHP:
Ver original
  1. <?php
  2. $text = '
  3. <a title="2" class="page" href="http://localhost/miweb/page/2/">2</a>
  4. <a title="3" class="page" href="http://localhost/miweb/page/3/">3</a>
  5. <span class="nextPage"><a href="http://localhost/miweb/page/4/">››</a>
  6. ';
  7.  
  8. $pattern = "/<a(\ |.+?)href=\"(.*?)\">([\w]+|[\W]+)<\/a>/";
  9.  
  10. $replace = '<a $1 href="#" onclick="avanza(\'$2\'); return false;">$3</a>';
  11. $text = preg_replace($pattern, $replace, $text);
  12. print_r($text);
  13. ?>
__________________
http://zital.no-ip.org
____________________

Euskerie ahuen eta bijotzan