title: Insert endline after all semicolons except the two in for loop
body: <p>I am writing a program which should insert an endline after every <code>; { }</code>. But there is a situation where my code inserts an endline after every <code>;</code>. The whole expression is in the string variable.</p>
  
  <pre><code>for(int i=0;i&lt;10;i++) { //any code}
  </code></pre>
  
  <p>It will convert it to</p>
  
  <pre><code>for(int i=0;
    i&lt;10;
    i++) {
     //any code
  }
  </code></pre>
  
  <p>I want the output to be like:</p>
  
  <pre><code>for(int i=0;i&lt;10;i++) {
     //anything  
  }
  </code></pre>
  
  <p>My code is: </p>
  
  <pre><code>StringBuilder sb = new StringBuilder(input);
  for (int i = 0; i &lt; sb.length(); i++) {
  
      if (sb.charAt(i) == ';' ) {
          sb.insert(i + 1, '\n');
      }
      if (sb.charAt(i) == '}') {
          sb.insert(i + 1, '\n');
      }
      if (sb.charAt(i) == '{') {
          sb.insert(i + 1, '\n');
      }
  }
  </code></pre>