111,122
社区成员
发帖
与我相关
我的任务
分享 string html = @"<TD class=tableGhf width=370 colSpan=3 widtd=""50%"">张三 </TD>
<TD class=tdbg1 width=113 widtd=""17%"">登证证书编号 </TD>
<TD class=tableGhf width=101 widtd=""17%"">未填写 </TD> </TR>
<TD class=tdbg1 width=102 widtd=""13%"">住址 </TD>
<TD class=tableGhf width=370 colSpan=3 height=20 widtd=""50%"">北京 </TD>
<TD class=tdbg1 width=113 widtd=""17%"">状态 </TD>
<TD class=tableGhf width=101 height=20 widtd=""17%"">违法未处理 </TD> ";
Regex reg = new Regex(@"(?is)<TD\sclass=tableGhf.*?>([^<]+)</TD>");
MatchCollection mc = reg.Matches(html);
Console.WriteLine("/*\n------输出结果------------");
foreach (Match m in mc)
{
Console.WriteLine( m.Groups[1].ToString());
}
Console.WriteLine("*/");
/*
------输出结果------------
张三
未填写
北京
违法未处理
*/
string html = @"<TD class=tableGhf width=370 colSpan=3 widtd=""50%"">张三 </TD>
<TD class=tdbg1 width=113 widtd=""17%"">登证证书编号 </TD>
<TD class=tableGhf width=101 widtd=""17%"">未填写 </TD> </TR>
<TD class=tdbg1 width=102 widtd=""13%"">住址 </TD>
<TD class=tableGhf width=370 colSpan=3 height=20 widtd=""50%"">北京 </TD>
<TD class=tdbg1 width=113 widtd=""17%"">状态 </TD>
<TD class=tableGhf width=101 height=20 widtd=""17%"">违法未处理 </TD> ";
Regex reg = new Regex(@"(?is)(?<=>)[^<]+(?=<)");
MatchCollection mc = reg.Matches(html);
Console.WriteLine("/*\n------输出结果------------");
foreach (Match m in mc)
{
Console.WriteLine( m.Groups[0].ToString());
}
Console.WriteLine("*/");
/*
------输出结果------------
张三
登证证书编号
未填写
住址
北京
状态
违法未处理
*/
"<[^>]+>"