diff --git a/include/blt/std/string.h b/include/blt/std/string.h index 6a6e476..8a6935a 100755 --- a/include/blt/std/string.h +++ b/include/blt/std/string.h @@ -170,6 +170,20 @@ namespace blt::string return tokens; } + static inline std::vector split(std::string s, char delim) + { + size_t pos = 0; + std::vector tokens; + while ((pos = s.find(delim)) != std::string::npos) + { + auto token = s.substr(0, pos); + tokens.push_back(token); + s.erase(0, pos + 1); + } + tokens.push_back(s); + return tokens; + } + // https://stackoverflow.com/questions/3418231/replace-part-of-a-string-with-another-string static inline bool replace(std::string& str, const std::string& from, const std::string& to) {