-
-
未解决
[求助]为什么C++ Regex正则匹配是龟速
-
发表于:
2020-4-17 21:11
3986
-
未解决 [求助]为什么C++ Regex正则匹配是龟速
我用Regex获取一个网页内容,编译型是Debug. 不管是调试还是单独运行. 都是龟速匹配. 一个普通的网页要匹配一分钟以上....
std::regex pattern(pText);
std::smatch reg_result;
std::string::const_iterator iterStart = Result.begin();
std::string::const_iterator iterEnd = Result.end();
while (regex_search(iterStart, iterEnd, reg_result, pattern)) {
iterStart = reg_result[0].second;
std::string tmpstr = reg_result[2];
OutputDebugStringA(tmpstr.c_str());
OutputDebugStringA("\n");
}
正则表达式:
<li\s+onmouseover=["'].+["']\s+onmouseout=["'].+["']>\s+<div\s+class=["'].+["']>\s+<div\s+class=["']img["']>\s+<a\s+href=["'](.+)["']\s+title=["'](.+)["']><img\s+src=["'](.*)["']\s+alt=["'].+["']\s+onerror=["']this.src=["'].+["']["']></a>\s+</div>\s+<div\s+style=["'].+["']\s+id=["'].+["']\s+class=["'].+["']>\s+<div>\s+.+<em>\d+</em>.+<br>\s+.+<em>\d+</em>.+<br>\s+.+<em>\d+</em>.+<br>\s+</div>\s+</div>\s+</div>\s+<div\s+class=["'].+["']>\s+<div\s+class=["'].+["']><a\s+href=["']\S+["']\s+title=["'].+["']>.+</a></div>\s+<div>.+<span\s+style=['"].+['"]>(\d+)</span>(.+)</div>\s+<div>.+<span\s+style=['"].+['"]>(\d+)</span>(.+)</div>\s+</div>\s+</li>
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2020-4-17 21:11
被ezrealik编辑
,原因: