新闻系统、blog关键字高亮效果

public static string Highlight(string Search_Str, string InputTxt)
  {
   Regex RegExp = new Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
   return RegExp.Replace(InputTxt, new MatchEvaluator(ReplaceKeyWords));
  }

  public static string ReplaceKeyWords(Match m)
  {
   return "<span style=color:black;BACKGROUND-COLOR:#ffff00;>" + m.Value + "</span>";
  }

posted on 2006-08-29 10:07  zenith  阅读(308)  评论(0编辑  收藏  举报

导航