求提取<td>和</td>之间内容的正则表达式

解决方案 »

  1.   

    这根本用不着正则表达式呀,你读出<td> </tb>的位置,然后读取之间内容就可以了。
      

  2.   

    还是正则方便
    <td[^>]*?>(?<content>[^\s\S]*?)</td>Haven't tested
      

  3.   

    string p = @"<td[^>]*?>(?<text>[^\s]*?)</td>";using System.Text.Reg....Regex reg = new Regex(p);
    Math m = reg.Match("<td>kkkkkkkkkkk</d>", RegexOptions.IgnoreCase);Console.WriteLine(m.groups["text"].Value);
      

  4.   

    上面那个没测试果然有一个错误,这次应改对了string content = @"<tr><td>a
    </td></tr>
    <tr>
    <td>
    bbs
    car
    </td>
    </tr>";
    Regex htmlRegex = new Regex(@"<td[^>]*?>(?<content>[\s\S]*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Compiled);MatchCollection mc = htmlRegex.Matches(content);
    for (int i=0; i<mc.Count; i++)
    {
    Console.WriteLine(mc[i].Groups["content"].Value);
    }