fork(7) download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. std::string s("ccc\r\naaa\r\ngggg");
  9. std::regex ee(R"((^|\r?\n)(?:aaa|bbb)(?=\r?\n|$))");
  10. std::string newtext = std::regex_replace( s, ee, "$1" );
  11. std::cout << newtext << std::endl;
  12.  
  13. }
Success #stdin #stdout 0s 3544KB
stdin
Standard input is empty
stdout
ccc

gggg