Strange regex problem

Dagur Páll Ammendrup dagurp at
Sun Mar 2 13:43:19 CET 2003

This code is enough to reproduce it for me:

#!/usr/bin/env python

import re

file = ''' <tr>
           <td class='forum1' width='5%' valign='middle'><{F_ACTIVE}></td>
           <td class='forum2' width='95%'><b>$total</b> 
            <td class='category' colspan='2'>$active[TOTAL] 
[.. A lot of HTML ..]

locations = []

p = re.compile('<!--START:(\w*?)-->')
m =
while m:
     begin = m.end()
     match =
     n ='<!--END:%s-->' % match,file,begin)
     m =,begin)

If i change the 2n line from the bottom to this:

q = re.compile('<!--END:%s-->' % match)
n =,begin)

this problem does not happen. Is there any change in speed because of 
this? Not that it matters much for the script I'm making.


Rene Pijlman wrote:
> Miki Tebeka:
>>>literal 45
>>>literal 73
>>>literal 66
>>>literal 70
>>>literal 95
>>>literal 71
> It looks like debug output. Are you running in some sort of
> debug mode?
>>2. Can you give us a sample input file?
> And some complete code we can run to reproduce the problem.

More information about the Python-list mailing list