Re: Error con las expresiones regulares

Chema Cortes <[email protected]>
Newsgroups gmane.comp.python.general.castellano
Message-ID <[email protected]>
El 12 de julio de 2009 21:45, xevi<[email protected]> escribió:
> Hola, estoy intentando usar expresiones regulares para recojer unos
> datos de un archivo html y me encuentro con que no me encuentra nada y
> no se si es que estoy haciendo algo mal o tengo algun error de sintaxis
> con las "/",un ejemplo del texto que intento encontrar es este:
> ...</font></strong></p>
>                        Recinto deportivo Agones de Pravia<br><br><br>
>
>
>                                <input name="calEvtLocation"...
>
> El codigo que ejecuto para encontrarlo es el siguiente:
>
> import re
> pattern = re.compile ('</font></strong></p>.*<input name="calEvtLocation"')
> result = pattern.search (codigo_html)
> if(result):
>        print "Texto:"+result.group()
>
> Por lo que entiendo y he leido deberia funcionar pero no llego a comprender porque falla

Mírate el flag re.DOTALL (también re.MULTILINE) si vas hacer búsquedas
multilíneas.

pattern = re.compile ('</font></strong></p>.*<input
name="calEvtLocation"', re.DOTALL)
_______________________________________________
Lista de correo Python-es 
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.