I have file test.html
<p>Just example code</p>
<div>
<img src="http:localhost/img1.jpg">
</div>
<p>Just example code2</p>
<div>
<img src="http:localhost/img1.jpg">
</div>
<p>Just example code3</p>
<div>
<img src="http:localhost/img1.jpg">
</div>
and i wanna with test.python replace in file just string with "img1.jpg" to "img2","img3" etc.
import string
s = open("test.html").read()
s = s.replace('http:localhost/img1.jpg','http:localhost/img2.jpg')
f = open("test2.html", 'w')
f.write(s)
f.close()
but program replace all img1 when i wanna replace all string img1 to img2,img3,img[i+1].
How to do it?