-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.cpp
More file actions
22 lines (19 loc) · 840 Bytes
/
Copy pathsplit.cpp
File metadata and controls
22 lines (19 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "split.h"
std::vector<std::string> pyfunc::split(std::string source, std::string splitter) {
std::vector<std::string> split_sources;
std::string split_source = "";
size_t end_index = 0;
size_t splitter_len = splitter.length();
while ((end_index = source.find(splitter)) != std::string::npos) {
split_sources.push_back(source.substr(0, end_index));
//split_sources.push_back(range(source ,0, end_index, 1));
source = source.substr(end_index + splitter_len);
//source = range(source, end_index+splitter_len, source.length(), 1);
}
split_sources.push_back(source);
return split_sources;
}
std::vector<std::string> pyfunc::split(std::string source, char splitter) {
std::string splitter_ = (std::string)"" + splitter;
return pyfunc::split(source, splitter_);
}