Kann boost::regex_search auf einem wstring durchgeführt werden?

Kann boost::regex_search auf einem wstring durchgeführt werden?


Folgendes habe ich versucht:


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;
}

Gefragt von coolface

Antworten:


Verwenden Sie wregex und wsmatch


Einige Code-Antworten


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;
}