C#正则表达式 委托替换

      MatchEvaluator myEvaluator = new MatchEvaluator(ReplaceCC);

            string sRegexInput = @"<INPUT.*?value=([0-9\.]*).*?>";  //替换input
            string sRegexSel = "<SELECT.*?selected>(.*?)</OPTION>.*?</SELECT>"; //替换sel

            string strWithOutInput = Regex.Replace(hnExcel.Value, sRegexInput, myEvaluator);
            string strWithOutSelect = Regex.Replace(strWithOutInput, sRegexSel, myEvaluator);

            sw.Write(header + strWithOutSelect);

 

protected static string ReplaceCC(Match m)
        {
            return m.Groups[1].Value;
        }

posted @ 2010-03-31 09:00  庚武  Views(296)  Comments(0Edit  收藏  举报