Changing every other instance of <B> in a file

Lars Klæboe larskl at klassekampen.no
Tue Mar 27 08:21:00 EST 2001


I have quite a few (~70000) quark tagged files I'd like to HTMLize, and
as my tool of choice has been python for every other script, I thought
I'd stick to what I know. Or thought I knew.

The original file.txt (quark tagged) :

	Blablabla <B> talktalk <B> blabla blabla balbalblabla

The resulting file.html (html)

	Blablabla <B> talktalk </B> blabla blabla balbalblabla

As you can tell, every other instance of <B> is to be changed into </B>.

How on earth can I do this as easy as I did in sed ? I'm stuck
mindwise, locked on a useless solution I'm too embarrased
to show you ;)

All help is appreciated !

-- 
Lars Klæboe




More information about the Python-list mailing list