Given the following input and regex strings:
const string inputString = "${Principal}*${Rate}*${Years}";
const string tokenMatchRegexString = @"\${([^}]+)}";
How can I replace each token (i.e. ${Principal}, ${Rate}, and ${Years}) with the return value of my 'ReplaceToken' function?
private static string ReplaceToken(string tokenString)
{
switch (tokenString)
{
case "Principal":
return GetPrincipal();
case "Rate":
return GetRate();
case "Years":
return GetYears();
default:
throw new NotImplementedException(String.Format("A replacment for the token '{0}' has not been implemented.", tokenString));
}
}
private static string GetPrincipal()
{
throw new NotImplementedException();
}
private static string GetRate()
{
throw new NotImplementedException();
}
private static string GetYears()
{
throw new NotImplementedException();
}