//public string HilightKeyword(string strValue)
    //{
    //    string keyword = Request.QueryString["keyword"];//搜索关键字
    //    string hilightValue = null;
    //    if (keyword != null)
    //    {
    //        string [] key = keyword.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    //        int keyCount = key.Length;
    //        strValue = InsertHtml(strValue, key, 0);
    //        for (int i = 1; i < keyCount; i++)
    //        {
    //            strValue = InsertHtml(strValue, key, i);
    //        }      
    //    }
    //    hilightValue = strValue;
    //    return hilightValue;
    //}    ////以下代码有BUG,需要处理
    //public string  InsertHtml(string strValue,string []key,int i) 
    //{
    //    MatchCollection mc = Regex.Matches(strValue, key[i], RegexOptions.IgnoreCase);
    //    for (int j = 0; j < mc.Count; j++)//循环在匹配的子串前后插代码
    //    {
    //        //这样会替换掉HTML标签中的字母,除非<>中的字符不去处理
    //        //j×31为插入html标签使keyword字符串增加的长度,注意下面两句不能交换位置,否则将出现HTML标签插入错误。
    //        strValue = strValue.Insert((mc[j].Index + key[i].Length + j * 31), "</span>");//先插入关键字后的html标签
    //        strValue = strValue.Insert((mc[j].Index + j * 31), "<span class='highlight'>");//关键字前插入html标签
    //    }
    //    return strValue;
    //}
-----------------
输入两个关键字 “a i” 是就出错,原因是插入的<span ..></span>里有‘i’。
所以现在我想,不让替换<span>标签里的字符,用正则表达式如何做到?
-------------