HTML Agility Pack is a great tool for manipulating and working with HTML: http://htmlagilitypack.codeplex.com/
It could at least make grabbing the values you need and doing the replaces a little easier.
Contains links to using the HTML Agility Pack: How to use HTML Agility pack