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

C# 中正则的运用...
<li> <a   href= "/s?kw=地区:丹阳&classid=6 "   target= "_blank "> 丹阳 </a> </li>

我怎样运用C#   中的正则来得到   地区:丹阳   这几个字...然后   把他替换成Server.UrlEncode(得到的汉字)
static   Main()
{
                  StreamReader   sr   =   new   StreamReader( "F:\\1.txt ");
                string   all   =   " ";
                all   =   sr.ReadToEnd();
                sr.Dispose();
                all   =   Regex.Replace(all,   这要怎写,   new   MatchEvaluator(CapText));
                StreamWriter   sw   =   new   StreamWriter( "F:\\1.txt ");
                sw.Write(all);
                Response.Write( "OK ");
}

static   string   CapText(Match   m)
        {
              *****************
              ************
                return   Server.UrlEncode(得到的汉字)
        }

------解决方案--------------------
try

@ "(? <=kw=)[^& " "]* "