这样的正则怎么写啊!
这样的正则怎么写啊!怎么才能获取到下面的 湖南地图 湖南电视 湖南电视台
<TR>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC">湖南地图</A></TD>
<TD>624 <SPAN class=up>↑ +11%</SPAN></TD>
<TD>0 <SPAN class=dn>↓ -100%</SPAN></TD>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC">查看</A></TD>
<TD> </TD></TR>
<TR>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3">湖南电视</A></TD>
<TD>181 <SPAN class=dn>↓ -25%</SPAN></TD>
<TD>6 <SPAN class=dn>↓ -54%</SPAN></TD>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3">查看</A></TD>
<TD> </TD></TR>
<TR>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8">湖南电视台</A></TD>
<TD>896 <SPAN class=dn>↓ -8%</SPAN></TD>
<TD>6 <SPAN class=dn>↓ -54%</SPAN></TD>
<TD><A
href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8">查看</A></TD>
<TD> </TD></TR>
--------------------编程问答-------------------- 没看明白什么意思 --------------------编程问答-------------------- 正在看正则,学习~~~
帮顶,期待高手 --------------------编程问答--------------------
--------------------编程问答--------------------
using System;
using System.Text.RegularExpressions;
public class Test
{
static void Main()
{
string strHtml = @"<TR>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC"">湖南地图 </A> </TD>
<TD>624 <SPAN class=up>↑ +11% </SPAN> </TD>
<TD>0 <SPAN class=dn>↓ -100% </SPAN> </TD>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC"">查看 </A> </TD>
<TD> </TD> </TR>
<TR>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3"">湖南电视 </A> </TD>
<TD>181 <SPAN class=dn>↓ -25% </SPAN> </TD>
<TD>6 <SPAN class=dn>↓ -54% </SPAN> </TD>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3"">查看 </A> </TD>
<TD> </TD> </TR>
<TR>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8"">湖南电视台 </A> </TD>
<TD>896 <SPAN class=dn>↓ -8% </SPAN> </TD>
<TD>6 <SPAN class=dn>↓ -54% </SPAN> </TD>
<TD> <A
href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8"">查看 </A> </TD>
<TD> </TD> </TR> ";
MatchCollection mc = Regex.Matches(strHtml, @"<TR>[\s\S]*?href="".*?>(.*?)</", RegexOptions.IgnoreCase);
for (int i = 0; i < mc.Count; i++)
{
Console.WriteLine(mc[i].Groups[1].Value);
}
//湖南地图
//湖南电视
//湖南电视台
Console.ReadKey();
}
}
强人正解 --------------------编程问答-------------------- \shref=""http://index.baidu.com/main/word.php?word=[^>]+>([^<]+)</a> --------------------编程问答--------------------
<TR>[\s\S]*?<TD>\s*?<A[^>]*?>(.+?)</A>取group[1] --------------------编程问答--------------------
Regex reg = new Regex(@"(?<=<TR>).*?<A[^>]*>([^/]+)?(?=</A>)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection mc= reg.Matches("htmlStr");
foreach(Match m in mc)
{
s += m.Groups[1].Value + ",";
}
s="湖南地图, 湖南电视, 湖南电视台 ,"; --------------------编程问答--------------------
补充:.NET技术 , ASP.NET