tinyregextemplating

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
					
public class Program
{
	public static void Main()
	{
		var template = "The {{Color}} {{Animal}} just jumps.";
		
		var map = new Dictionary<string,string>(){
			{"Color", "red"},
			{"Animal", "Cobra"}
		};
		
		var result = Regex.Replace(template, @"{{(\w+)}}", m => map[m.Groups[1].Value]);
		Console.WriteLine(result);
	}
}
;