Use replace-regexp-in-string instead of replacing in a temp buffer.

It's more obvious this way.