vvb2060
2021-05-26 01:21:54 +08:00
committed by John Wu
parent 34e5a7cd24
commit 79e8962854
4 changed files with 97 additions and 39 deletions

View File

@@ -188,3 +188,16 @@ string &replace_all(string &str, string_view from, string_view to) {
}
return str;
}
vector<string> split(const string& s, const string& delimiters) {
vector<string> result;
size_t base = 0;
size_t found;
while (true) {
found = s.find_first_of(delimiters, base);
result.push_back(s.substr(base, found - base));
if (found == string::npos) break;
base = found + 1;
}
return result;
}