[Tutor] best search/replace method?

John Washakie washakie at gmail.com
Wed Apr 25 21:47:26 CEST 2007


I'm writing a program which will read in an html file, and then
replace certain elements, such as the title, and various paths defined
for images. I can make a 'source' file with ImagePathReplaceMe and
TitleReplaceMe text in it, then search for that and replace it. With
sed my script would be three lines:

cat raw.html |
sed 's/ImagePathReplaceMe/NewPathToImage/g' |
sed 's/TitleReplaceMe/NewTitle/g' > new.html

However, this is going to be part of an Plone product so I want to use
Python. What is the best method to accomplish this?


More information about the Tutor mailing list