in reply to Templates on the cheap?

Something quite close to this got hashed out in the thread REGEX: multiple search and replace.