Hi, I'm using following method to highlight the keywords in a given text.
private string HighlightSearchKeyWords(string searchKeyWord, string text)
{
Regex keywordExp = new Regex(@" ?, ?");
var pattern = @"\b(" + keywordExp.Replace(Regex.Escape(searchKeyWord), @"|") + @")\b";
Regex exp = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
return exp.Replace(text, @"<span class=""search-highlight"">$0</span>");
}
Sample Text: "What is .net Programming? Pl suggest few e-books"
Keyword: ".net"
When i try to search with key word ".net" .net is not getting highlighted in the given sample text.
When i try to search with key word "e-books" e-books is getting highlighted in the given sample text.
What would be the problem. Can anyone pl let me know where exactly do i need modify/