fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. cout << regex_replace("123", regex("(?=(2))(?=9*0)|2"), "<$1>") << '\n';
  10. cout << regex_replace("123", regex("(?=(2))(?=9*0)|\\d"), "<$1>") << '\n';
  11. cout << regex_replace("123", regex("(?=(2))(?=9*0)|."), "<$1>") << '\n';
  12. cout << '\n';
  13. cout << regex_replace("123", regex("(?=(1))(?=(2))(?=(3))(?=9*0)|(.)"), "<$4>: <$1><$2><$3>\n") << '\n';
  14. cout << regex_replace("123", regex("(?=(1))(?=(2))(?=(3))(?=0)|(.)"), "<$4>: <$1><$2><$3>\n") << '\n';
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 3548KB
stdin
Standard input is empty
stdout
1<2>3
<><2><>
<><2><>

<1>: <1><><>
<2>: <><><>
<3>: <><><>

<1>: <1><><>
<2>: <><><>
<3>: <><><>