fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <string>
  4. #include <regex>
  5.  
  6. int main() {
  7. std::string s = "1Hi15This10";
  8.  
  9. std::regex number("(\\d+)");
  10. auto begin = std::sregex_iterator(s.begin(), s.end(), number);
  11.  
  12. for (auto i = begin; i != std::sregex_iterator(); ++i) {
  13. std::cout << " " << i->str() << '\n';
  14. }
  15. }
Success #stdin #stdout 0s 3556KB
stdin
Standard input is empty
stdout
  1
  15
  10