Last active
March 21, 2016 14:45
-
-
Save sergey-shambir/bb7b379d0d35a15457cc to your computer and use it in GitHub Desktop.
функция SplitWords на базе boost::trim и boost::split.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Используем split для разбиения текста на слова | |
// предикат, возвращённый функцией 'boost::is_space()', отмечает пробельные символы как разделители | |
// token_compress_on гарантирует склеивание нескольких пробельных символов в один | |
// 'boost::trim' убирает пробельные символы в начале и в конце (иначе в words окажутся пустые слова). | |
vector<string> SplitWords(string const& text) | |
{ | |
std::string trimmed = boost::trim_copy(text); | |
vector<string> words; | |
boost::split(words, trimmed, boost::is_space(), boost::token_compress_on); | |
return words; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment