fork download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::regex reg("/?([^/]+)/?$");
  7. std::string s("/home/fypj/build/simple-loops.cc/");
  8. std::cout << std::regex_replace(s, reg, "/$1/$1/") << std::endl;
  9.  
  10. return 0;
  11. }
Success #stdin #stdout 0s 3552KB
stdin
Standard input is empty
stdout
/home/fypj/build/simple-loops.cc/simple-loops.cc/