using System.Text.RegularExpressions;
public static void Main()
string orig = "hello_{new}";
string replacement = "there $& I am $0 being replaced";
var newStrA = Regex.Replace(orig, "{new}", replacement);
Console.WriteLine("Regex Replace with $& and $n:");
Console.WriteLine($"\t{newStrA}");
var newStrB = Regex.Replace(orig, "{new}", replacement.Replace("$", "$$"));
Console.WriteLine("Regex Replace with escaped $& and $n:");
Console.WriteLine($"\t{newStrB}");