Ver Mensaje Individual
  #15 (permalink)  
Antiguo 07/04/2010, 14:00
Avatar de mayid
mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: Encontrar html con expresiones regulares

Hay! Pero el ungreedy es tan necesario!

Me encantaría poder mostrarte el codigo que tengo que filtrar. Probe el tuyo y me hace selecciones enormes, casi de paginas enteras, te diría.

Pero no sigamos. Creo el gran decisor puede ser el flag:

Cita:
$patron = '/<a[^>]*>(.(?!a>))*<h[32]>.*<\/h[32]>.*<\/a>/isU'; //|<a.*>.*<h3>(.*)<\/h3>.*<\/a> // [^(<\/a>)]+
//$patron = '/<a name="(.*)">(.*)<\/a>/isU';

preg_match_all($patron, trim($section['sections']), $subtitle, PREG_SET_ORDER);

for($i=0;$i<count($subtitle);$i++){
if (isset($subtitle[$i][0])){
$subtitulos[] = strip_tags(trim($subtitle[$i][0]), "<a>");
}
}
Aun no estoy tan suelto con estas expresiones como para asegurar que algo funcione.