re.findall() hangs in python

Peter Otten __peter__ at web.de
Sun Apr 1 02:58:51 EDT 2007


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)
> 
>         print "before find all"
> 
>         match = re.findall(pattern, data)
> 
>         if (match):
>            print "match2"
> 
> 
> 
> Can you please tell me why it that?

Could it be that it is just slow? If not, post a small example of data that
provokes findall() to hang.

Peter



More information about the Python-list mailing list