#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
std::vector<std::string> SplitStringMultiDelim(const std::string& s,
const std::string& delims)
{
std::string temp = s;
// Replace each delimiter with a space
for (char d : delims)
std::replace(temp.begin(), temp.end(), d, ' ');
std::istringstream iss(temp);
std::vector<std::string> tokens;
std::string word;
while (iss >> word)
tokens.push_back(word);
return tokens;
}
int main()
{
std::string s = "-c, c++.. c#:: -java ,php...python";
// delimiters: space, comma, dot, colon, dash
std::string delims = " ,.: -";
std::vector<std::string> tokens = SplitStringMultiDelim(s, delims);
for (const auto& w : tokens)
std::cout << w << std::endl;
}
/*
run:
c
c++
c#
java
php
python
*/