[2.5.1] Str.Replace() doesn't work?

G

Gilles Ganault

Hello

I need to parse an HTML file where records aren't homogenous, so I
figured I could run a first loop to add an unused character at the
beginning of each record, and then run a second loop to actually parse
each record.

I can't figure out why the script is not returning anything in the
"for m in matches" block:

=========
f = open("input.txt", "r")
response = f.read()
f.close()

#Pass 1: Add some character to separate records
#response.replace('<li class="N2"','µ<li class="N2"')
reponse = response.replace('<li class="N2"','µ<li class="N2"')
p = re.compile('µ')
index=1
matches = p.finditer(response)
#Python doesn't display anything :-/
for m in matches:
print "Found %s" % str(index)
index = index + 1
=========

Any idea what I could be doing wrong?

Thank you for any tip.
 
G

Gilles Ganault

I can't figure out why the script is not returning anything in the
"for m in matches" block:

Pfff, found it 5mn after posting ;-)

s/reponse =/response =/

Sorry guys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top