fork(1) download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. #include <time.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string data("int main(){// Singleline content\n /* start always points to the first node of the linked list.\n temp is used to point to the last node of the linked list.*/\n node *start,*temp;\n start = (node *)malloc(sizeof(node));\n temp = start;\n temp -> next = NULL;\n temp -> prev = NULL;\n /* Here in this code, we take the first node as a dummy node.\n The first node does not contain data, but it used because to avoid handling special cases\n in insert and delete functions.\n */\n printf(\"1. Insert\n\");");
  10. //std::cout << "Data: " << data << std::endl;
  11. std::regex pattern(R"(//.*|/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)");
  12. std::smatch result;
  13.  
  14. while (regex_search(data, result, pattern)) {
  15. std::cout << std::regex_replace(result[0].str(), std::regex(R"((^|\n)[^\S\r\n]+)"), "$1") << std::endl;
  16. data = result.suffix().str();
  17. }
  18. }
Success #stdin #stdout 0s 3504KB
stdin
Standard input is empty
stdout
// Singleline content
/* start always points to the first node of the linked list.
temp is used to point to the last node of the linked list.*/
/* Here in this code, we take the first node as a dummy node.
The first node does not contain data, but it used because to avoid handling special cases
in insert and delete functions.
*/