http://tieba.baidu.com/p/1907619590
上边是网址。我请求的是此页的html
"date":"(?<post_time>.*?)"[\s\S]*?class="louzhubiaoshi"[\s\S]*?<cc><div id="post_content.*?>(?<content>[\s\S]*?)</div></cc>
这是c#正则代码。但匹配matchcollection进行循环很慢。有点卡。但用下边的正则。
class="louzhubiaoshi"[\s\S]*?<cc><div id="post_content.*?>(?<content>[\s\S]*?)</div></cc>
却很快。为什么会这样?有没高效的写法?
我想实现匹配出楼主发的帖子的这个正则!
上边是网址。我请求的是此页的html
"date":"(?<post_time>.*?)"[\s\S]*?class="louzhubiaoshi"[\s\S]*?<cc><div id="post_content.*?>(?<content>[\s\S]*?)</div></cc>
这是c#正则代码。但匹配matchcollection进行循环很慢。有点卡。但用下边的正则。
class="louzhubiaoshi"[\s\S]*?<cc><div id="post_content.*?>(?<content>[\s\S]*?)</div></cc>
却很快。为什么会这样?有没高效的写法?
我想实现匹配出楼主发的帖子的这个正则!
@"(?is)<div\s*class=""l_post noborder""[^>]*?""date"":""(?<time>[^""]+).*?class=""louzhubiaoshi""(?=[^>]*?author=""(?<lz>[^""]+)"")[^>]+.*?<cc><div(?=[^>]*?id=""post_content_\d+"")[^>]+>(?<content>((?<g><div)|(?<-g></div>)|(?!</?div).)*(?(g)(?!)))</div>");
while (m.Success)
{
Console.WriteLine(m.Groups["time"].Value);
Console.WriteLine(m.Groups["lz"].Value);
Console.WriteLine(m.Groups["content"].Value);
m = m.NextMatch();
}