using System.Text.RegularExpressions; Regex.Replace("String containing pattern", "(con.*ern)+", match => match.Groups[0].Value.ToUpper())); // "String CONTAINING PATTERN" Regex.Replace("helo world", "(h)(.*?)(l)", "H$2$3$3") // "Hello world" new Regex("pattern").Replace("pattern pattern pattern", "replaced", 1)) // first occurance // "replaced pattern pattern"string str = "Hello, [World]!"; string pattern = @"\[.*?\]"; string replacement = "Universe"; string replacedStr = Regex.Replace(str, pattern, replacement); Console.WriteLine(replacedStr); // Output: "Hello, Universe!"