fork download
  1. #include <iostream>
  2. #include <regex>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. string text = "\/*comment 1*\/text1\n\/*comment 2*\/text2\n";
  8. string pattern = "([\\s\\S]*?)((?:\/\\*[\\s\\S]+?\\*\/)|$)";
  9. regex re(pattern);
  10. cout << "pattern: " << pattern << endl;
  11. cout << regex_replace(text,re,"$2");
  12. return 0;
  13. }
Success #stdin #stdout 0s 15344KB
stdin
Standard input is empty
stdout
pattern: ([\s\S]*?)((?:/\*[\s\S]+?\*/)|$)
/*comment 1*//*comment 2*/