using System.Collections.Generic;
using System.Text.RegularExpressions;
private static string MyProcess(string text, IDictionary<string, string> replacements) => Regex.Replace(
match => replacements.TryGetValue(match.Groups["name"].Value, out var value) ? value : "???");
public static void Main() {
Dictionary<string, string> replacements =
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
string greet = "Hi {name}! Are you from {country}?";
string result = MyProcess(greet, replacements);
Console.WriteLine(result);