affiliate marketing Dot Net Posts: how to Search string for the exact word match in c#

Friday, 24 June 2011

how to Search string for the exact word match in c#

Regex.IsMatch("Hello1 Hello2", "\bHello\b");


Something like this method below should work for you every time:


static bool ExactMatch(string input, string match)
{
return Regex.IsMatch(input, string.Format(@"\b{0}\b", Regex.Escape(match)));

}

No comments:

Post a Comment