当前位置: 代码迷 >> ASP.NET >> C# 中正则的运用.解决办法
  详细解决方案

C# 中正则的运用.解决办法

热度:826   发布时间:2013-02-25 00:00:00.0
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=)[^& " "]* "
  相关解决方案