Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.file, std.regex, std.stdio;
- void main(string[] args)
- {
- if (args.length != 2)
- return;
- auto text = readText(args[1]);
- enum common = `((?:func|for|if|else)[^{\n]*)\n`;
- text = replaceAll(text, ctRegex!(common ~ `\t*\{` ), "$1 {\n" );
- text = replaceAll(text, ctRegex!(common ~ `([^\n]+)\n` ), "$1 {\n$2 }\n");
- text = replaceAll(text, ctRegex!( `\}(\s+)else`), "$1} else" );
- write(text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement