fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <regex>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. auto parse(const string& input, const string& delimiter) {
  10. const regex re("([^" + delimiter + "]+)" + delimiter + '?');
  11.  
  12. return vector<string>(sregex_token_iterator(input.begin(), input.end(), re, 1), sregex_token_iterator());
  13. }
  14.  
  15. int main() {
  16. const string str("0,1,2,4444444444;5,6,7,8888888888;.9,10,11,12121212;.");
  17. vector<vector<vector<long long>>> foo;
  18.  
  19. for (auto& i : parse(str, "\\.")) {
  20. foo.resize(foo.size() + 1);
  21. for (auto& j : parse(i, ";")) {
  22. foo.back().resize(foo.back().size() + 1);
  23. for (auto& k : parse(j, ",")) {
  24. foo.back().back().push_back(stoll(k));
  25. }
  26. }
  27. }
  28.  
  29. for (auto& i : foo) {
  30. for (auto& j : i) {
  31. for (auto& k : j) {
  32. cout << k << endl;
  33. }
  34. cout << endl;
  35. }
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 3508KB
stdin
Standard input is empty
stdout
0
1
2
4444444444

5
6
7
8888888888

9
10
11
12121212