I have email subjects stored in DB like this "Sample Result {MM/dd/yyyy}" or "Sample {MM/dd/yyyy} Result". I need to get the string and replace the date format with current date. The date formats in the string might vary for example it can be "{dd-MM-yyyy}" also. If the data in DB was like "Sample Result {0:MM/dd/yyyy}" I can use the below code:
string.Format(formattedSubject, DateTime.Now)
But how to make it work with "Sample Result {MM/dd/yyyy}" I know I can use:
string formattedSubject = subject.Replace("{","{0:");
But I think that's not the ideal solution. Any other ideas?