fork(4) 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}\n"s;
  9.  
  10. cout << input << regex_replace(input, regex("(.+?)\\s*\\{?\\s*(.+?;)\\s*\\}?\\s*"), "$1 {\n\t$2\n}\n") << endl;
  11. }
Success #stdin #stdout 0s 3548KB
stdin
Standard input is empty
stdout
if (KnR)
	foo();
if (spaces) {
    foo();
}
if (allman)
{
	foo();
}
if (horstmann)
{	foo();
}
if (pico)
{	foo(); }
if (whitesmiths)
	{
	foo();
	}
if (KnR) {
	foo();
}
if (spaces) {
	foo();
}
if (allman) {
	foo();
}
if (horstmann) {
	foo();
}
if (pico) {
	foo();
}
if (whitesmiths) {
	foo();
}