<td class="MAIN_TD_PRICE">550元</td>
<td class="MAIN_TD_PRICE">650元</td>
<td class="MAIN_TD_PRICE">750元</td>
<td class="MAIN_TD_PRICE">850元</td>
<td class="MAIN_TD_PRICE">950元</td>
如何取出 550 650 750 850 950???

解决方案 »

  1.   

    Regex.Match(str,"<td class="MAIN_TD_PRICE">(\d+)").Groups[1].Value;
      

  2.   

    你已经得到<td class="MAIN_TD_PRICE">550元 </td> 
    <td class="MAIN_TD_PRICE">650元 </td> 
    <td class="MAIN_TD_PRICE">750元 </td> 
    <td class="MAIN_TD_PRICE">850元 </td> 
    <td class="MAIN_TD_PRICE">950元 </td> 这个字符串了吗?没有的话怎么能用正则取呢。。还是给td取id,然后循环取值吧。。
      

  3.   

            string str = "<td class=\"MAIN_TD_PRICE\">550元 </td>";
            string parrentStr = "<td class=\"MAIN_TD_PRICE\">(.+?)\\s+</td>";
            Match ma = Regex.Match(str, parrentStr, RegexOptions.IgnoreCase);
            if (ma.Success)
            {
                Response.Write(ma.Groups[1]);
            }仅供参考
      

  4.   

    <td class="MAIN_TD_PRICE"><Label id="RMB1" Text="550元"></Lable> </td> 
    其他的一样.用ID.Text就可以取了.有个问题,楼主用表格的话为什么不用GridView呢?
      

  5.   

    Regex.Match(str," <td class="MAIN_TD_PRICE">(\d+)").Groups[1].Value;
    也可以的
      

  6.   


                string str = @"<td class=""MAIN_TD_PRICE"">550元 </td>
    <td class=""MAIN_TD_PRICE"">650元 </td>
    <td class=""MAIN_TD_PRICE"">750元 </td>
    <td class=""MAIN_TD_PRICE"">850元 </td>
    <td class=""MAIN_TD_PRICE"">950元 </td> ";
                foreach (Match match in Regex.Matches(str, @"<td[^>]*>(\d+)元\s*</td>"))
                    Console.WriteLine(match.Groups[1].Value);
    /*
    输出:
    550
    650
    750
    850
    950
    */
      

  7.   

                string str = "<td class=\"MAIN_TD_PRICE\">550元 </td><td class=\"MAIN_TD_PRICE\">650元 </td> <td class=\"MAIN_TD_PRICE\">750元 </td> <td class=\"MAIN_TD_PRICE\">850元 </td> <td class=\"MAIN_TD_PRICE\">950元 </td>";
                Regex re = new Regex("<td class=\"MAIN_TD_PRICE\">(\\d+)");
                MatchCollection mc = re.Matches(str);
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Groups[1].Value);
                }