Пример #1
0
static std::vector<std::string>
split(std::string const& s)
{
    std::vector<std::string> parts;
    std::regex ws_re("\\s+");
    std::copy(std::sregex_token_iterator(s.begin(), s.end(), ws_re, -1),
              std::sregex_token_iterator(), std::back_inserter(parts));
    return parts;
}
Пример #2
0
 std::vector<std::string> Split(const std::string& input, const std::string& regex)
 {
     std::regex ws_re(regex); // whitespace
     std::vector<std::string> out;
     std::copy(std::sregex_token_iterator(input.begin(), input.end(), ws_re, -1),
         std::sregex_token_iterator(),
         std::back_inserter(out));
     return out;
 }