using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string html = @"...
<div class=""cntent commin"">
<div class=""confl"">
<div class=""newTit"">
<h2>文章标题</h2>
</div>
<div class=""readCount"">
<h4><span>时间:2014-9-2 16:18:15</span>
...
<div class=""xiangguan"" style=""margin-right:0px;"">
<h2>相关新闻</h2>
<ul>
...";
Regex rexXxbt = new Regex(@"(?is)(?<=\<div\sclass\=\""newTit\""\>\r\n\s+\<h2\>).*?(?=\<\/h2\>\r\n\s+\<\/div\>)");
Console.WriteLine(rexXxbt.Match(html).Value);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string html = @"...
<div class=""cntent commin"">
<div class=""confl"">
<div class=""newTit"">
<h2>文章标题</h2>
</div>
<div class=""readCount"">
<h4><span>时间:2014-9-2 16:18:15</span>
...
<div class=""xiangguan"" style=""margin-right:0px;"">
<h2>相关新闻</h2>
<ul>
...";
Regex rexXxbt = new Regex(@"(?is)(?<=\<div\sclass\=\""newTit\""\>\r\n\s+\<h2\>).*?(?=\<\/h2\>\r\n\s+\<\/div\>)");
Console.WriteLine(rexXxbt.Match(html).Value);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货