using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class Program
{
static void Main(string[] args)
var str = "Something @Model.xxx something @Model.yyy";
var result = Regex.Replace(str, @"@Model\.([xy]{3})", match => $"$${match.Groups[1]}$$");
Console.Write(result);
}