110,534
社区成员
发帖
与我相关
我的任务
分享
<tr>
<th width="12%" align="right" class="td_red_01"><strong>负责人</strong></th>
<td colspan="3" class="td_red_01">王先生</td>
</tr>
<tr>
<th align="right"><strong>联系电话:</strong></th>
<td width="38%"> <img src='http://aaa.html' />
</td>
<th width="12%" align="right"><strong>邮编</strong></th>
<td width="38%">420400</td>
</tr>
<tr>
<th width="12%" align="right" class="td_red_01"><strong>负责人</strong></th>
<td colspan="3" class="td_red_01">李先生</td>
</tr>
<tr>
<th align="right"><strong>联系电话:</strong></th>
<td width="38%"> <img src='http://bbb.html' />
</td>
<th width="12%" align="right"><strong>邮编</strong></th>
<td width="38%">420400td>
</tr>
string str = @"<tr>
<th width=""12%"" align=""right"" class=""td_red_01""><strong>负责人</strong></th>
<td colspan=""3"" class=""td_red_01"">王先生</td>
</tr>
<tr>
<th align=""right""><strong>联系电话:</strong></th>
<td width=""38%""> <img src='http://aaa.html' />
</td>
<th width=""12%"" align=""right""><strong>邮编</strong></th>
<td width=""38%"">420400</td>
</tr>";
Regex reg = new Regex(@"(?is)负责人.*?<td[^>]*?>(?<man>.*?)</td>.*?联系电话:.*?<td[^>]*?>(?<phone>.*?)</td>.*?邮编.*?<td[^>]*?>(?<code>.*?)</td>");
foreach (Match m in reg.Matches(str))
Console.WriteLine("{0} {1} {2}", m.Groups["man"].Value, m.Groups["phone"].Value, m.Groups["code"].Value);
Console.ReadLine();
string str = File.ReadAllText(@"E:\a.txt",Encoding.GetEncoding("gb2312"));//换成你的内容
Regex reg = new Regex(@"(?<=<td[^>]*?>)(?:(?!</?td).)*");
foreach (Match m in reg.Matches(str))
Console.WriteLine(m.Value);
Console.ReadLine();