using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
ReplaceMultipleWithIgnoreCaseText();
public static void ReplaceMultipleWithIgnoreCaseText()
const string template = "My name is @Name@ and I like to read about @SUBJECT@ on @website@, tag @subject@";
const string expected = "My name is Alex and I like to read about C# on stackoverflow.com, tag C#";
var replaceParameters = new List<KeyValuePair<string, string>>
new KeyValuePair<string, string>("@name@","Alex"),
new KeyValuePair<string, string>("@subject@","C#"),
new KeyValuePair<string, string>("@website@","stackoverflow.com"),
var actual = ReplaceMultiple(template, replaceParameters);
Console.WriteLine(template);
Console.WriteLine(expected);
Console.WriteLine(actual);
public static string ReplaceMultiple(
IEnumerable<KeyValuePair<string, string>> replaceParameters)
foreach(var replace in replaceParameters)
var templateSplit = Regex.Split(result,
RegexOptions.IgnoreCase);
result = string.Join(replace.Value, templateSplit);