SolemnJoker
4/16/2019 - 2:45 AM

split

split a string

inline
std::vector<std::string> split(const std::string& str, char seperator) {
    std::vector<std::string> results;

    std::string::size_type start = 0;
    std::string::size_type sep = str.find(seperator);
    while (sep != std::string::npos) {
        if (start < sep)
            results.emplace_back(str.substr(start, sep - start));

        start = sep + 1;
        sep = str.find(seperator, start);
    }

    if (start != str.size())
        results.emplace_back(str.substr(start));

    return results;
}