Imagine we have following PHP code:
if (true)
{
doSomething();
}
But we want to have:
if (true) {
doSomething();
}
I figure we can use the Perl in-place mass edit facility to make this sort of change across an entire codebase.
But I just cannot get it to match a newline followed by whitespace then a brace.
Here's what I'm trying
perl -pi -w -e 's/if(.*)\n\s+\{/if$1 \{/g' testfile.php
I'm at a complete loss; it matches if I don't include the whitespace and brace. But that's not very helpful.