re.findall() hangs in python
7stud
bbxx789_05ss at yahoo.com
Sun Apr 1 03:13:37 EDT 2007
On Mar 31, 9:12 pm, "silverburgh.me... at gmail.com"
<silverburgh.me... at gmail.com> wrote:
> Hi,
>
> 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?
It doesn't hang when I try it. Why don't you post a complete example
that hangs.
Also, you might consider using exterior single quotes around your
string so that you don't have to escape double quotes inside the
string.
More information about the Python-list
mailing list