foreach(Match m in Regex.Matches(html,@"(?is)<a[^>]+>([^<>]+)</a>.*?<font[^>]+>([^<>]+)</font>")) { Console.WriteLine(m.Groups[1].Value); Console.WriteLine(m.Groups[2].Value); }
/* 嵌入式平台 (ARM) 中国 (CHINA) 美国 (America) */ }
>([^<>]+)< 可以这样
foreach (Match m in Regex.Matches(html, @"(?<=(>))(\w+)(?=(</a>))|(?<=(>))(.+)(?=(</font>))")) { Console.WriteLine(m.Value); }
void Main()
{
string html=@"<td width=""50%"">
<b><a href=""/browse/A"">嵌入式平台</a></b>
<font size=1>(ARM)</font>
</td>
<td width=""50%"">
<b><a href=""/browse/B"">中国</a></b>
<font size=1>(CHINA)</font>
</td>
<td width=""50%"">
<b><a href=""/browse/C"">美国</a></b>
<font size=1>(America)</font>
</td>";
foreach(Match m in Regex.Matches(html,@"(?is)<a[^>]+>([^<>]+)</a>.*?<font[^>]+>([^<>]+)</font>"))
{
Console.WriteLine(m.Groups[1].Value);
Console.WriteLine(m.Groups[2].Value);
}
/*
嵌入式平台
(ARM)
中国
(CHINA)
美国
(America) */
}
可以这样
{
Console.WriteLine(m.Value);
}
void Main()
{
string html=@"<td width=""50%"">
<b><a href=""/browse/A"">嵌入式平台</a></b>
<font size=1>(ARM)</font>
</td>
<td width=""50%"">
<b><a href=""/browse/B"">中国</a></b>
<font size=1>(CHINA)</font>
</td>
<td width=""50%"">
<b><a href=""/browse/C"">美国</a></b>
<font size=1>(America)</font>
</td>";
foreach(Match m in Regex.Matches(html,@">([^<>\s]+)<"))
{
Console.WriteLine(m.Groups[1].Value);
}
/*
嵌入式平台
(ARM)
中国
(CHINA)
美国
(America)
*/
}