C++ STL 正则表达式 非常的慢

如题 同样给的正则表达式,同样的测试文本,stl正则速度很慢,目前解决办法是用boost的正则表达式后速度提升不少 代码如下

// header file
#include <boost\regex.hpp> 
//
static boost::wregex expression(L"[a-zA-Z_0-9-]+(\\.[a-zA-Z0-9-]+)*@([a-zA-Z0-9])+(\\.[a-zA-Z0-9-]+)+");
	//boost::wsmatch what;

	wstring::iterator start = str_in.begin();
	wstring::iterator end = str_in.end();
	boost::match_results<wstring::iterator> what;
	//boost::wsmatch
	boost::match_flag_type flags = boost::match_default;

	//bool b = boost::regex_search(str_in, what, expression);
    // exist exception
	try
	{
		while (boost::regex_search(start, end, what, expression, flags))
		{
			//if (what[0].matched)
			//{
			vStr_out.push_back(what[0]);
			//}
			// update search position:
			start = what[0].second;
			// update flags: 
			flags |= boost::match_prev_avail;
			flags |= boost::match_not_bob;
		}
	}
	catch (CMemoryException* e)
	{
		return;
	}
	catch (CFileException* e)
	{
		return;
	}
	catch (boost::exception& e)
	{
		return;
	}

 

上一篇:English Debate Notes Sample


下一篇:Mint Linux 安装 DotnetCore 遭遇无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系