I'd advise you to use a string template library like CTemplate from google:
http://code.google.com/p/google-ctemplate/[
^]. I like the
StringTemplate Library[
^] best, but there is no MFC version for that. Originally it was developed in Java and runs parallel to the equally excellent
ANTLR[
^] project. There is a .NET port available for the StringTemplate Library as well as ANTLR.
Hope this was helpful to you.
Cheers!