string p = @"<td[^>]*?>(?<text>[^\s]*?)</td>";using System.Text.Reg....Regex reg = new Regex(p); Math m = reg.Match("<td>kkkkkkkkkkk</d>", RegexOptions.IgnoreCase);Console.WriteLine(m.groups["text"].Value);
上面那个没测试果然有一个错误,这次应改对了string content = @"<tr><td>a </td></tr> <tr> <td> bbs car </td> </tr>"; Regex htmlRegex = new Regex(@"<td[^>]*?>(?<content>[\s\S]*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Compiled);MatchCollection mc = htmlRegex.Matches(content); for (int i=0; i<mc.Count; i++) { Console.WriteLine(mc[i].Groups["content"].Value); }
<td[^>]*?>(?<content>[^\s\S]*?)</td>Haven't tested
Math m = reg.Match("<td>kkkkkkkkkkk</d>", RegexOptions.IgnoreCase);Console.WriteLine(m.groups["text"].Value);
</td></tr>
<tr>
<td>
bbs
car
</td>
</tr>";
Regex htmlRegex = new Regex(@"<td[^>]*?>(?<content>[\s\S]*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Compiled);MatchCollection mc = htmlRegex.Matches(content);
for (int i=0; i<mc.Count; i++)
{
Console.WriteLine(mc[i].Groups["content"].Value);
}