我的c++怎么了?正则表达式匹配
我正在用 c++ 编写一个 robots.txt 解析器,
boost::regex exrp( "^User-agent:\s*(.*)");
boost:: match_results<string::const_iterator> what;
if(boost::regex_search( robots, what, exrp ) )
{
string s( what[1].first, what[1].second );
cout<< s;
}
这应该与名称为 * 的用户代理匹配,但它返回所有数据
i am writing an robots.txt parser in c++
boost::regex exrp( "^User-agent:\s*(.*)");
boost:: match_results<string::const_iterator> what;
if(boost::regex_search( robots, what, exrp ) )
{
string s( what[1].first, what[1].second );
cout<< s;
}
this should match the useragent with name * but it it returns all datas
如果您不使用 c++0x 原始字符串,则需要双反斜杠 '\\'。
You need the double backslash '\\' if you don't use c++0x raw strings.