using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var keyword = "A+"; Console.WriteLine("Unambiguous WB: " + Regex.Replace("A+B and A++", $@"(?$&")); keyword = "Hello"; Console.WriteLine("Regular WB: " + Regex.Replace("Hello World! Hello,World!", $@"\b{keyword}\b", "$&")); Console.WriteLine("Whitespace WB: " + Regex.Replace("Hello, Hello Hello!", $@"(?$&")); keyword = "hello"; Console.WriteLine("Case innsensitive: " + Regex.Replace("Hello, hello World!", Regex.Escape(keyword), "$&", RegexOptions.IgnoreCase)); } }