fork(16) download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4. using namespace std;
  5.  
  6. int main() {
  7. string str("abcdefabcghiabc");
  8. int i = 0;
  9. regex rgx1("abc");
  10. smatch smtch;
  11. while (regex_search(str, smtch, rgx1)) {
  12. std::cout << i << ": " << smtch[0] << std::endl;
  13. i += 1;
  14. str = smtch.suffix().str();
  15. }
  16.  
  17. return 0;
  18. }
  19.  
  20.  
  21.  
Success #stdin #stdout 0s 3544KB
stdin
Standard input is empty
stdout
0: abc
1: abc
2: abc