fork download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. string test = "##### stuff ## #";
  10. string test2 = "##### stuff ## #";
  11. int index;
  12. while( (index = test.find("#")) != string::npos )
  13. {
  14. test.replace(index, 1, "hash");
  15. }
  16. while( (index = test2.find("##")) != string::npos )
  17. {
  18. test2.replace(index, 2, "hash");
  19. }
  20. cout<<test<<endl;
  21. cout<<test2<<endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
hashhashhashhashhash stuff hashhash hash
hashhash# stuff hash #