ssplit() added ignore_remainder bool

This commit is contained in:
aristocratos 2021-05-20 15:03:33 +02:00
parent d17c6d475a
commit 9a901a4fba
1 changed files with 2 additions and 2 deletions

View File

@ -260,7 +260,7 @@ namespace Tools {
}
//* Split <string> at <delim> <time> number of times (0 for unlimited) and return vector
vector<string> ssplit(string str, string delim = " ", int times = 0){
vector<string> ssplit(string str, string delim = " ", int times = 0, bool ignore_remainder=false){
vector<string> out;
if (times > 0) out.reserve(times);
if (!str.empty() && !delim.empty()){
@ -274,7 +274,7 @@ namespace Tools {
if (times > 0 && ++x >= times) break;
}
}
out.push_back(str);
if (!ignore_remainder) out.push_back(str);
return out;
}