【发布时间】:2010-12-06 22:15:10
【问题描述】:
这是我尝试过的:
std::wstring extractText(std::wstring line) {
std::wstring text;
boost::regex exp("^.*?PRIVMSG #.*? :(.+)");
boost::smatch match;
if (boost::regex_search(line, match, exp)) {
text = std::wstring(match[1].first, match[1].second);
}
return text;
}
【问题讨论】:
-
当你尝试它时发生了什么?
-
错误 C2784: 'bool boost::regex_search(const std::basic_string
&,const boost::basic_regex &,boost::regex_constants:: match_flag_type)' : 无法从 'boost::smatch' 中推断出 'const boost::basic_regex &' 的模板参数 -
我相信当你使用
std::wstring时,你将不得不使用boost.regex的'w'形式,比如boost::wregex和boost::wsmatch。此外,如果您进行 Unicode 匹配,请查看此链接:boost.org/doc/libs/1_45_0/libs/regex/doc/html/boost_regex/…