fork(11) download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string regx = R"(<\s*(\d+)\s*>((.|\n)*?)<\s*\1\s*>)";
  9. string input = "<1>test1<1><2>Tes \n t2<2>sfsaf<3><4>test4<4>";
  10. smatch matches;
  11. while (regex_search(input, matches, regex(regx)))
  12. {
  13. cout<<matches[2]<<endl;
  14. input = matches.suffix().str();
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3556KB
stdin
Standard input is empty
stdout
test1
Tes 
 t2
test4