fork(1) download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. const auto input = "if (KnR)\n\tfoo();\nif (spaces) {\n foo();\n}\nif (allman)\n{\n\tfoo();\n}\nif (horstmann)\n{\tfoo();\n}\nif (pico)\n{\tfoo(); }\nif (whitesmiths)\n\t{\n\tfoo();\n\t}"s;
  9.  
  10. //cout << input << endl;
  11.  
  12. cout << regex_replace(input, regex("(.+?)\\s*\\{?\\s*(.+?;)\\s*\\}?\\s*"), "$1 {\n\t$2\n}\n") << endl;
  13. }
Success #stdin #stdout 0s 3504KB
stdin
Standard input is empty
stdout
if (KnR) {
	foo();
}
if (spaces) {
	foo();
}
if (allman) {
	foo();
}
if (horstmann) {
	foo();
}
if (pico) {
	foo();
}
if (whitesmiths) {
	foo();
}