#include <iostream>
#include <vector>
#include <regex>
using namespace std;
int main() {
string s("aaa1bbb2ccc");
regex r("([0-9])");
vector<std::string> tokens(sregex_token_iterator(s.begin(), s.end(), r, {-1, 0}), sregex_token_iterator());
for (string t: tokens) cout << t << ", "; // aaa, 1, bbb, 2, ccc,
}
#include <iostream>
#include <vector>
#include <regex>
using namespace std;
int main() {
string s("123aaa");
regex r("([0-9])");
vector<std::string> tokens(sregex_token_iterator(s.begin(), s.end(), r, {-1, 0}), sregex_token_iterator());
for (string t: tokens) cout << t << ", "; // , 1, , 2, , 3, aaa,
}