title: Python - substitute parts of C programs, but skip comments
body: <p>using Python and regular expressions I need to add one space on either side of each assignment operator in C programs, but skip the operators in comments:</p>
  
  <pre><code>int x;
  int y=100;
  x=y;
  // a=b+c
  /* i=j+k */
  </code></pre>
  
  <p>the above needs to be translated to:</p>
  
  <pre><code>int x;
  int y = 100;
  x = y;
  // a=b+c
  /* i=j+k */
  </code></pre>
  
  <p>I have tried with this regex to skip single line comments:</p>
  
  <pre><code>try:
      source = re.sub(r'(?&lt;!//)(.*)([^\s])=([^\s])', r'\1\2 = \3', source)
  except Exception as e:
      pass
  </code></pre>
  
  <p>but it is not working.</p>
  
  <p>Thanks for any help.</p>