I need to highlight search terms in a block of text.
My initial thought was looping though the search terms. But is there an easier way?
Here is what I'm thinking using a loop...
public string HighlightText(string inputText)
{
    string[] sessionPhrases = (string[])Session["KeywordPhrase"];
    string description = inputText;
    foreach (string field in sessionPhrases)
    {
        Regex expression = new Regex(field, RegexOptions.IgnoreCase);
        description = expression.Replace(description, 
                                         new MatchEvaluator(ReplaceKeywords));
    }
    return description;
}
public string ReplaceKeywords(Match m)
{
    return "<span style='color:red;'>" + m.Value + "</span>";
}
 
     
     
     
    