fork download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. regex rx1("(2|25)");
  7. regex rx2("(25|2)");
  8. string s = "2225";
  9.  
  10. for (sregex_iterator it(s.begin(), s.end(), rx1), end; it != end; ++it) {
  11. cout << it->position() << ": " << it->str() << endl;
  12. }
  13.  
  14. cout << endl;
  15.  
  16. for (sregex_iterator it(s.begin(), s.end(), rx2), end; it != end; ++it) {
  17. cout << it->position() << ": " << it->str() << endl;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3544KB
stdin
Standard input is empty
stdout
0: 2
1: 2
2: 2

0: 2
1: 2
2: 25