匹配 TD, TR 中的内容
string s = "<table><TR><td>1111</td></tr><tr><td>2222</td></tr><tR><td>333</td></tr></table><tr><td>qqqqq</t><tr>WWWWWWW</tr></tr>";
//(?<=<tr>)向前匹配<tr>,不包含
//[\s\S]*?
//(?=</tr>)向后匹配</tr>,不包含
MatchCollection mc = Regex.Matches(s, @"(?<=<tr>)[\s\S]*?(?=</tr>)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
Console.Write(m.Value);
}
输出结果:
<td>1111</td>
<td>22 22</td>
<td>333</td>
<td>qqqqq</t><tr>WWWWWWW