<td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层01号房</div>  <div align='center'  style='cursor:hand' onclick=' openContent(302273);'><img src='/images/house/ks.gif' border='0'></div></td> <td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层02号房</div>  <div align='center'  style='cursor:hand' onclick=' openContent(302274);'><img src='/images/house/ks1.gif' border='0'></div></td> 
<td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层03号房</div>  <div align='center'  style='cursor:hand' onclick=' openContent(302275);'><img src='/images/house/ks.gif' border='0'></div></td> 
..
..
..
还有很多个
<td height='68'...>...</td>
<td height='68'...>...</td>我应该怎么获得302273  /images/house/ks.gif
              302274  /images/house/ks1.gif
              302275  /images/house/ks.gif
              ..       ..
              ..       ..
              ..       ..

解决方案 »

  1.   

            private static void TestRegex18()
            {
                string html = @"<td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层01号房</div> <div align='center' style='cursor:hand' onclick=' openContent(302273);'><img src='/images/house/ks.gif' border='0'></div></td>  <td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层02号房</div> <div align='center' style='cursor:hand' onclick=' openContent(302274);'><img src='/images/house/ks1.gif' border='0'></div></td>  
    <td height='68' width='140' bgcolor='#EFF6FB'><div align='center'>1单元18层03号房</div> <div align='center' style='cursor:hand' onclick=' openContent(302275);'><img src='/images/house/ks.gif' border='0'></div></td>  ";
                MatchCollection mc = Regex.Matches(html, @"(?is)<div[^<>]+?openContent\((?<id>\d+).+?<img src='(?<url>[^']+)");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Groups["id"].Value + "," + m.Groups["url"].Value);
                }
            }