<tr>
    <td><span class="cGreen">免费</span></td>
    <td>[<a href="../sort/68_1.htm">音频播放</a>]</td>    <td><a href="../soft/84962.htm"><font color=#0033cc>Super MP3 Download 3.3.1.2</font></a></td>
    <td>2009-12-21</td>
    <td class="cBlack">3845KB</td>
  </tr>
求正则表达式  要求提取出“免费”,两个href,音频播放,Super MP3 Download 3.3.1.2,2009-12-21,3845KB

解决方案 »

  1.   

    try...            Regex regTd = new Regex(@"(?is)<td[^>]*>(?:(?!</?td\b).)*</td>");
                Regex regCon = new Regex(@"<[^>]*>");
                MatchCollection mc = regTd.Matches(yourStr);
                foreach (Match m in mc)
                {
                    richTextBox2.Text += regCon.Replace(m.Value, "") + "\n";
                }
      

  2.   

    免费
    (?<=<span[^<]*>).*?(?=</span>)href
    (?<=href="[^"]*).*(?=")
      

  3.   

    感谢您的回帖
    能不能帮我改成这种形式的        foreach (Match NextMatch in Matches)
            {
                string free = NextMatch.Groups["Link"].Value.ToString().Trim();
                string softname = NextMatch.Groups["softName"].Value.ToString().Trim();
                .....
            }
      

  4.   

    try...            Regex reg = new Regex(@"(?is)<td><span class=""cGreen"">(?<free>[^<]*)</span></td>\s*<td>\[<a href=""(?<typeLink>[^>]*)"">(?<type>[^<]*)</a>\]</td>\s*<td><a href=""(?<softLink>[^>]*)""><font color=#0033cc>(?<softName>[^<]*)</font></a></td>\s*<td>(?<date>[^<]*)</td>\s*<td class=""cBlack"">(?<size>[^<]*)</td>");
                MatchCollection mc = reg.Matches(yourStr);
                foreach (Match m in mc)
                {
                    richTextBox2.Text += m.Groups["free"].Value + "\n";
                    richTextBox2.Text += m.Groups["typeLink"].Value + "\n";
                    richTextBox2.Text += m.Groups["type"].Value + "\n";
                    richTextBox2.Text += m.Groups["softLink"].Value + "\n";
                    richTextBox2.Text += m.Groups["softName"].Value + "\n";
                    richTextBox2.Text += m.Groups["date"].Value + "\n";
                    richTextBox2.Text += m.Groups["size"].Value + "\n";
                }