Created an extension method and it works for normal words but When I added an @ as part of search keyword it stopped working. Can someone help?
public static class Extensions
{
public static string ReplaceWholeWord(this string inputString, string oldValue, string newValue)
{
string pattern = @"\b@test\b"; // @"\b$\b".Replace("$",oldValue);
return Regex.Replace(inputString, pattern, newValue);
}
}
static void Main(string[] args)
{
string input = "@test, and @test but not testing. But yes to @test";
input = input.ReplaceWholeWord("@test", "text");
Console.WriteLine(input);
}