in reply to How do I speed this up?

I should have also noted that, if you build such a regular expression, you can then eval it to do the replacements.