23inline std::vector<std::string>
split(
const std::string& input,
const char delimiter, int64_t limit = -1) {
25 std::vector<std::string> out;
26 std::transform(input.begin(), input.end(), std::back_inserter(out), [](
const char& chr) {
27 return std::string(1, chr);
30 }
else if (limit == 0) {
32 }
else if (input.empty()) {
36 std::vector<std::string> out;
37 std::stringstream stream(input);
40 while (getline(stream, line, delimiter)) {
47 std::stringstream remainder;
48 remainder << stream.rdbuf();
49 std::string res = remainder.str();
52 }
else if (input.at(input.size() - 1) == delimiter) {
68inline std::vector<std::string>
split(
const std::string& input,
const std::string& delimiter, int64_t limit = -1) {
69 if (delimiter.size() == 1) {
70 return split(input, delimiter[0], limit);
71 }
else if (delimiter.size() == 0) {
72 return split(input, 0, limit);
73 }
else if (limit == 0) {
75 }
else if (input.empty()) {
79 std::vector<std::string> out;
84 while ((pos = input.find(delimiter, index)) != std::string::npos) {
86 token = input.substr(index, pos - index);
87 index = pos + delimiter.size();
94 if (index < input.size()) {
95 out.push_back(input.substr(index));
96 }
else if (index == input.size()) {
123inline void replaceAll(std::string& input,
const std::string& find,
const std::string& replaceWith,
size_t limit = 0) {
130 while ((pos = input.find(find, pos)) != std::string::npos) {
131 input.replace(pos, find.length(), replaceWith);
132 pos += replaceWith.length();
134 if (++count == limit) {