using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = "This is a /Sample Text: in a sentence"; var oldValue = "/Sample Text:"; var newValue = "sample text"; var matchCase = RegexOptions.IgnoreCase; var result = Regex.Replace(text, $@"(?!\B\w){Regex.Escape(oldValue)}(?