Re:What programming languages are used most on weekends?
by sokoloff on Tuesday February 07, 2017 @11:06PM
(#13595656)
The question specification is such that you don't need special handling of comments, strings, etc. "every paren" isn't qualified as "that is part of the code".
The point of the question is more to gauge your understanding of/familiarity with available tools and ability to think laterally rather than immediately jump to "I've got to write some real code to solve this"
I like sed. I like perl one-liners. I would consider it a mistake to try to do this on a real codebase in a batch manner with just a regexp. You'd be far better off googling to find a source code formatter that includes a real parser, like clang-format.