日期:2014-05-19  浏览次数:20450 次

十万火急这个正则怎么写呢
<td   style= "text-align:   left "> <a   href= "/s/player/0620D18E42C6F7294099FA1974586BBE.html "   target= "_blank "> 1   集 </a>   <a   href= "/s/player/602CEAD555EE87CE56034491DCDF3EBD.html "   target= "_blank "> 2   集 </a>   <a   href= "/s/player/877E8C415146DA022251FA422787EB85.html "   target= "_blank "> 3   集 </a>   <a   href= "/s/player/0C3F13A7BA4A573D67FA7F4DF330C0A3.html "   target= "_blank "> 4   集 </a>   <a   href= "/s/player/6F835A38592EFBE67140D57DC22253D6.html "   target= "_blank "> 5   集 </a>   <a   href= "/s/player/B5F6734D3CE49A80EBE74B33F6D16B28.html "   target= "_blank "> 6   集 </a>   <a   href= "/s/player/0438727CC1AF5F82E2F9A92BD9FB6B7E.html "   target= "_blank "> 7   集 </a>   <a   href= "/s/player/B2710901B93035190B77D532137A5F81.html "   target= "_blank "> 8   集 </a>   <a   href= "/s/player/B414527097DF01523925365EB514B278.html "   target= "_blank "> 9   集 </a>   <a   href= "/s/player/AEE2A72A4DBB7321D2EBCD082A7E11DC.html "   target= "_blank "> 10   集 </a>   <a   href= "/s/player/B83BE35CA46EB1706FFC36BAF71C4976.html "   target= "_blank "> 11   集 </a>   <a   href= "/s/player/0CC268A80A8786D12E5E76B0A989DB07.html "   target= "_blank "> 12   集 </a>   <a   href= "/s/player/4D3128028D3BE1B307ADE855BA3FA833.html "   target= "_blank "> 13   集 </a>   <a   href= "/s/player/8B1A011B5821F3FAD0219BEFB3DD141C.html "   target= "_blank "> 14   集 </a>   <a   href= "/s/player/E4CD4B837AE4CE86003A08EC6F801C71.html "   target= "_blank "> 15   集 </a>   <a   href= "/s/player/9063ED30E4953785E1680EFD362C28F7.html "   target= "_blank "> 16   集 </a>   <a   href= "/s/player/1F83F454CE85CBE6FCD6F24F16049B2E.html "   target= "_blank "> 17   集 </a>   <a   href= "/s/player/3456AEB7151B8D87248B2A0B494FBECC.html "   target= "_blank "> 18   集 </a>   </td>
我要获得对应的url和集数,要怎么写正则呢?谢谢!

------解决方案--------------------

string yourStr = richTextBox1.Text;
MatchCollection mc = Regex.Matches(yourStr, @ " <a\s+href= " "(? <link> [^ " "]*?) " "[^> ]*?> (? <name> [^ <]*?) </a> ",RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups[ "link "] + "\n "; //url链接
richTextBox2.Text += m.Groups[ "name "] + "\n "; //集数
}