110,539
社区成员
发帖
与我相关
我的任务
分享
<div id="endText">
<p>我国首次并购美飞机制造商(图<br />资料图片</p>
<p>商报消息 随着中国低空开放的信号越来越强,国内的航空制造企业开始提前布局。记者从中国航空工业集团公司(以下简称“中航工业”)获悉,该公司旗下通用飞机公司已与全球第二大通用飞机制造商美国西锐飞机工业公司签订全资收购协议。这是中国航空工业史上首次对欧美发达国家飞机整机制造企业的收购案。</p>
</div>
MatchCollection mc = Regex.Matches(yourHtml,@"(?is)(?<=<div\s[^>]*?id=\x22endText\x22[^>]*>((?!</?div).)*?)<p[^>]*>.+?</p>");
foreach(Match m in mc)
{
m.Value;//就是你需要的
}
MatchCollection mc = Regex.Matches(yourHtml,@"(?is)(?<=<div\s[^>]*?id="endText"[^>]*>((?!</?div).)*?)<p[^>]*>.+?</p>");
foreach(Match m in mc)
{
m.Value;//就是你需要的
}
string str = "<div id=\"endText\"><p>我国首次并购美飞机制造商(图<br />资料图片</p>"
+ "<span>商报消息span 随着中国低空开放的信号越来越强。</span><p>商报消息p 随着中国低空开放的信号越来越强。</p>"
+ "<div>商报消息div 随着中国低空开放的信号越来越强。</div></div>";
Regex reg = new Regex(@"(?is)<div[^>]*?id=""endText""[^>]*?>(.*?)</div>");
Regex reg1 = new Regex(@"<p>.*?</p>");
MatchCollection match = reg.Matches(str);
foreach (Match m in match)
{
foreach (Match mm in reg1.Matches(m.Groups[1].Value))
{
Response.Write(mm.Value + "<br/>");
}
}
//一句的写不来 等待大侠来解决
<div id="endText">
<p>我国首次并购美飞机制造商(图<br />资料图片</p>
<p>商报消息 随着中国低空开放的信号越来越强。</p>
<span>商报消息 随着中国低空开放的信号越来越强。</span>
<div>商报消息 随着中国低空开放的信号越来越强。</div>
</div>
<p>我国首次并购美飞机制造商(图<br />资料图片</p>
<p>商报消息 随着中国低空开放的信号越来越强。</p>
string str = "<div id=\"endText\"><p>我国首次并购美飞机制造商(图<br />资料图片</p><p>商报消息"
+"随着中国低空开放的信号越来越强,国内的航空制造企业开始提前布局。记者从中国航空工业集团公"
+"司(以下简称“中航工业”)获悉,该公司旗下通用飞机公司已与全球第二大通用飞机制造商美国西"
+"锐飞机工业公司签订全资收购协议。这是中国航空工业史上首次对欧美发达国家飞机整机制造企业的收购案。</p></div>";
Regex reg = new Regex(@"(?is)<div[^>]*?id=(['""\s]?)endText\1[^>]*?>(?<html>.*?)</div>");
MatchCollection match = reg.Matches(str);
foreach (Match m in match)
{
Response.Write(m.Groups["html"].Value + "<br/>");
}
string str = "<div id=\"endText\"><p>我国首次并购美飞机制造商(图<br />资料图片</p><p>商报消息"
+"随着中国低空开放的信号越来越强,国内的航空制造企业开始提前布局。记者从中国航空工业集团公"
+"司(以下简称“中航工业”)获悉,该公司旗下通用飞机公司已与全球第二大通用飞机制造商美国西"
+"锐飞机工业公司签订全资收购协议。这是中国航空工业史上首次对欧美发达国家飞机整机制造企业的收购案。</p></div>";
Regex reg = new Regex(@"<div[^>]*?id=(['""\s])endText\1[^>]*?>(?<html>.*?)</div>");
MatchCollection match = reg.Matches(str);
foreach (Match m in match)
{
Response.Write(m.Groups["html"].Value + "<br/>");
}