日期:2014-05-18  浏览次数:20803 次

这个代码转成c# 如何写呀?
var cacheData = cnt.innerHTML;
  var searchDate = function () {
  var key = document.getElementById("search").value;
  var patten = new RegExp("("+key+")","gi");
  document.getElementById("cnt").innerHTML = cacheData.replace(patten,"<i style='color:red'>$1</i>");
  };

这个代码转成c# 如何写呀?

------解决方案--------------------
C# code
 public string searchData(string key,string value)
            {
                Regex _reg = new Regex(@"(?im)(" + key + ")");
                value = _reg.Replace(value, @"<i style='color:red'>$1</i");
                return value;
            }