title: A regular expression that moves opening { braces to a new line, for C/C++/PHP/etc code
body: <p>This kind of code structure makes, IMHO, code less readable:  </p>
  
  <pre><code>int func() {
    [...]
  }</code></pre>
  
  <p>It's just a matter of taste, but I prefer this one:</p>
  
  <pre><code>int func()
  {
    [...]
  }</code></pre>
  
  <p>So I've trying to make a regular expression to apply in my text editor in order to make code in the first example look like the second one.  </p>
  
  <p>I've come up with something like <code>^([\t]*)([^\t{]*)({.*)$</code> ( I don't remember exactly if it was like this )<br>
  The idea is that when a <code>{</code> is found preceded of non-space characters, most probably the function header or a control structure, then split the line and send the <code>{</code> to the next line, but preserving the indent level (I.E. the same amount of tabs) of the original line.  </p>
  
  <p>The last part, about keeping the indent level is what I can't get right.<br>
  Any help appreciated.  </p>
  
  <p>--<br>
  PS: Feel free to disagree with my coding standards but please remember that's not the main subject here.</p>