Hi,
I am using following code to Highlighting keywords in a text or resume.
My code:
string keywords = ".net";
string text = "These are technologies: .net, intranet, NET, net,ASP.net.";
Response.Write(HighlightKeywords(keywords, text));
private static string HighlightKeywords(string text,string keywords)
{
// Swap out the ,<space> for pipes and add the braces
Regex r = new Regex(@", ?");
keywords = "(" + r.Replace(keywords, @"|") + ")";
// Get ready to replace the keywords
r = new Regex(keywords, RegexOptions.Singleline | RegexOptions.IgnoreCase);
// Do the replace
return r.Replace(text, new MatchEvaluator(MatchEval));
}
private static string MatchEval(Match match)
{
if (match.Groups[1].Success)
{
return "<b><font color='red'>" + match.ToString() + "</font></b>";
}
return ""; //no match
}
The output should be shown as
These are technologies: .net, intranet, NET, net,ASP.net.
but it showing as:
These are technologies: .net, intranet, NET, net,ASP.net.
please help me
Thanks in advance
Pankaj