I'm stuck with this simple problem. Say I have a string which is consisted from characters [0-9]. What I would like to do is split the string by the single characters using boost::split.
std::string str = "0102725";
std::vector<std::string> str2;
boost::split(str2, str, boost::is_any_of(SOMETHING));
I'm looking for SOMETHING so that str2[0] contains "0", str2[1] contains "1", str2[2] contains "0" and so on. So far I have tried "", ':' and ":" but no luck...
boost::split
is overkill for that.
for (size_t i=0; i < str.length(); i++)
str2.push_back(std::string(1, str.at(i)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With