std::vector<std::string> split(const std::string& str, const std::string& separator)
{
std::vector<std::string> str_result;
if (str.empty() || separator.empty()){return str_result;}
std::string::size_type pos = str.find_first_of(separator);
if (pos != std::string::npos)
{
str_result.emplace_back(str.substr(0, pos));
while (pos != std::string::npos)
{
std::string::size_type next = str.find(separator, pos + separator.size());
std::string str_temp_sub;
if (next != std::string::npos)
{
str_temp_sub = str.substr(pos + separator.size(), next - (pos + separator.size()));
str_result.emplace_back(str_temp_sub);
}
else
{
str_temp_sub = str.substr(pos + separator.size(), -1);
str_result.emplace_back(str_temp_sub);
}
pos = next;
}
}
return str_result;
}
int main()
{
for (auto& v : split("285894_A789646_65489", "_"))
std::cout << v << std::endl;
}