fork download
  1. #include <stdio.h>
  2. #include <string>
  3. #include <iostream>
  4. #include <regex>
  5. using namespace std;
  6.  
  7. class A
  8. {
  9. public:
  10. A()
  11. {
  12. cout<<"A--"<<endl;
  13. }
  14. ~A()
  15. {
  16. cout<<"A~~"<<endl;
  17. }
  18.  
  19. };
  20. A a;
  21. int main ()
  22. {
  23. string str = "Hello_2018!";
  24. regex pattern("Hello");
  25. cout << regex_replace(str, pattern, "") << endl; //输出:_2018,将Hello替换为""
  26. cout << regex_replace(str, pattern, "Hi") << endl; //输出:Hi_2018,将Hello替换为Hi
  27. //cout << regex_replace(string("'3kejr"), pattern, "Hi") << endl; //输出:Hi_2018,将Hello替换为Hi
  28. char ring_path[128];
  29. snprintf(ring_path, sizeof(ring_path), "%spoint.wav\n", "/2343/43/");
  30. printf("%s", ring_path);
  31. int i=0;
  32. do
  33. {
  34. i++;
  35. A b;
  36. }while(i<10);
  37. }
Success #stdin #stdout 0s 4300KB
stdin
Standard input is empty
stdout
A--
_2018!
Hi_2018!
/2343/43/point.wav
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A--
A~~
A~~