fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4. #include <regex>
  5.  
  6. int main() {
  7. std::string Text = "111:222:333";
  8. std::regex RegExp(":");
  9. std::vector<std::string> Vector = {};
  10. // заполняем вектор
  11. std::copy(std::sregex_token_iterator(Text.begin(), Text.end(), RegExp, -1),
  12. std::sregex_token_iterator(),
  13. std::back_inserter(Vector));
  14. // печатаем вектор
  15. for(const auto &i:Vector) std::cout << i << "\n";
  16. return 0;
  17. }
Success #stdin #stdout 0s 3560KB
stdin
Standard input is empty
stdout
111
222
333