当前位置: 代码迷 >> ASP.NET >> 这个正则如何写呢
  详细解决方案

这个正则如何写呢

热度:7307   发布时间:2013-02-26 00:00:00.0
十万火急这个正则怎么写呢
<td   style= "text-align:   left "> <a   href= "/s/player/0620D18E42C6F7294099FA1974586BBE "   target= "_blank "> 1   集 </a>   <a   href= "/s/player/602CEAD555EE87CE56034491DCDF3EBD "   target= "_blank "> 2   集 </a>   <a   href= "/s/player/877E8C415146DA022251FA422787EB85 "   target= "_blank "> 3   集 </a>   <a   href= "/s/player/0C3F13A7BA4A573D67FA7F4DF330C0A3 "   target= "_blank "> 4   集 </a>   <a   href= "/s/player/6F835A38592EFBE67140D57DC22253D6 "   target= "_blank "> 5   集 </a>   <a   href= "/s/player/B5F6734D3CE49A80EBE74B33F6D16B28 "   target= "_blank "> 6   集 </a>   <a   href= "/s/player/0438727CC1AF5F82E2F9A92BD9FB6B7E "   target= "_blank "> 7   集 </a>   <a   href= "/s/player/B2710901B93035190B77D532137A5F81 "   target= "_blank "> 8   集 </a>   <a   href= "/s/player/B414527097DF01523925365EB514B278 "   target= "_blank "> 9   集 </a>   <a   href= "/s/player/AEE2A72A4DBB7321D2EBCD082A7E11DC "   target= "_blank "> 10   集 </a>   <a   href= "/s/player/B83BE35CA46EB1706FFC36BAF71C4976 "   target= "_blank "> 11   集 </a>   <a   href= "/s/player/0CC268A80A8786D12E5E76B0A989DB07 "   target= "_blank "> 12   集 </a>   <a   href= "/s/player/4D3128028D3BE1B307ADE855BA3FA833 "   target= "_blank "> 13   集 </a>   <a   href= "/s/player/8B1A011B5821F3FAD0219BEFB3DD141C "   target= "_blank "> 14   集 </a>   <a   href= "/s/player/E4CD4B837AE4CE86003A08EC6F801C71 "   target= "_blank "> 15   集 </a>   <a   href= "/s/player/9063ED30E4953785E1680EFD362C28F7 "   target= "_blank "> 16   集 </a>   <a   href= "/s/player/1F83F454CE85CBE6FCD6F24F16049B2E "   target= "_blank "> 17   集 </a>   <a   href= "/s/player/3456AEB7151B8D87248B2A0B494FBECC "   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 "; //集数
}
  相关解决方案