title: Regex to add spaces around '=' in C++ code, what have I done wrong?
body: <p>I would like to create a regex which will allow me to add spaces around assignment operators in C++ code (as I prefer this style), e.g. so that</p>
  
  <pre><code>x=something
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>x = something
  </code></pre>
  
  <p>but </p>
  
  <pre><code>if(y==x)
  </code></pre>
  
  <p>does not become </p>
  
  <pre><code>if(y = = x)
  </code></pre>
  
  <p>and so on including <code>!=</code>,<code>&lt;=</code>,<code>&gt;=</code></p>
  
  <p>I am relatively new to regular expressions and have tried the following:</p>
  
  <pre><code>(?&lt;![\s=])(=)(?!=)
  </code></pre>
  
  <p>I thought this would be a good starter, but this does not seem to match. Could someone explain what I have not understood about regex here?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Example using regex which does not match in Code::Blocks IDE</p>
  
  <p><img src="https://i.stack.imgur.com/7x4tj.png" alt="Code::BLocks regex attempt"></p>