re.findall() hangs in python

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Apr 1 03:58:43 EDT 2007


En Sun, 01 Apr 2007 03:58:51 -0300, Peter Otten <__peter__ at web.de>  
escribió:

> silverburgh.meryl at gmail.com wrote:
>
>> I have the following regular expression.
>> It works when 'data' contains the pattern and I see 'match2' get print
>> out.
>> But when 'data' does not contain pattern, it just hangs at
>> 're.findall'
>>
>> pattern = re.compile("(.*)<img (.*?) src=\"(.*?)img(.*?)\"(.*?)",
>> re.S)
>
> Could it be that it is just slow? If not, post a small example of data  
> that
> provokes findall() to hang.

I bet it is very slooooooow!
To the OP: do you actually need all those groups? Specially the first and  
last (.*), they match all the surrounding text.

-- 
Gabriel Genellina




More information about the Python-list mailing list