输入hello ,把字符中的 hello 前后加<b>和</b> ,字符中的hello包括多种情况 Hello,heLLo...
这里hello 是变量,hello是举例。

解决方案 »

  1.   

    String a = "hellosjofdsjiHello";
    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[hH][eE][lL]{2}[oO]");
    System.Text.RegularExpressions.MatchCollection matchs = regex.Matches(a);
    a = regex.Replace(a, "***");
    regex = new System.Text.RegularExpressions.Regex("[*]{3}");
    for (int i = 0; i < matchs.Count; i++)
    {
        a = regex.Replace(a, "<b>" + matchs[i].Value + "</b>", 1);
    }
      

  2.   

    "<b>"+Hello+"</b>"也能解决啊
      

  3.   

    硬规则:
    最前面+<b>
    ,替换成</b>,<b>
    末尾+</b>