Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/12/2012, 14:02
Avatar de JorM
JorM
 
Fecha de Ingreso: diciembre-2012
Ubicación: Argentina
Mensajes: 53
Antigüedad: 11 años, 4 meses
Puntos: 2
De acuerdo Respuesta: preg_match_all - afinar expresión regular

Cita:
Ejemplo:
http://juanito.perez.com/solucion/ayuda?1.php
http://juanito.perez.com/consultas/consultas?44.php
http://otraweb.com/problema/ayuda?23.php

extraer solo urls que comiencen por "http://juanito.perez.com/solucion/"... en este caso el output sería: http://juanito.perez.com/solucion/ayuda?1.php
Si quieres que solo extraiga los Links que empiezan con "http://juanito.perez.com/solucion/" podría ser asi:

Código PHP:
Ver original
  1. <?php
  2. $str = '
  3. http://juanito.perez.com/solucion/ayuda?1.php
  4. http://juanito.perez.com/consultas/consultas?44.php
  5. http://otraweb.com/problema/ayuda?23.php
  6. http://juanito.perez.com/solucion/ejemplo.php
  7. http://juanito.perez.com/solucion/ejemplo2?var1=1&var2=2.php';
  8.  
  9. $expr = '#http:\/\/juanito\.perez\.com\/solucion\/.+\.php#'; //EXPRESION
  10. $mCount = preg_match_all($expr,$str,$arrMatches);
  11. foreach($arrMatches[0] as $values){
  12.   echo $values.'<br/>';
  13. }
  14. ?>

lo he probado y funciona.
Espero te sirva!!
Saludos!