Strange regex problem
Dagur Páll Ammendrup
dagurp at heimsnet.is
Sun Mar 2 07:43:19 EST 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>
$birth_lang<br>$birthusers</td>
</tr>
<!--START:skin_boards-->
<!--IBF_START_FUNC|ActiveUsers|$active-->
<tr>
<td class='category' colspan='2'>$active[TOTAL]
{ibf.lang.active_users}</td>
</tr>
[.. A lot of HTML ..]
<!--IBF_END_FUNC|subheader-->
<!--END:skin_boards-->
<!--IBF_START_FUNC|append_view|$url=""-->
'''
locations = []
p = re.compile('<!--START:(\w*?)-->')
m = p.search(file)
while m:
begin = m.end()
match = m.group(1)
n = re.search('<!--END:%s-->' % match,file,begin)
m = p.search(file,begin)
If i change the 2n line from the bottom to this:
q = re.compile('<!--END:%s-->' % match)
n = q.search(file,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.
-Dagur
Rene Pijlman wrote:
> Miki Tebeka:
>
>>OP:
>>
>>>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