title: Regex: match certain code that is NOT commented out
body: <p>I'm looking for all code branch points in a 1000 line piece of code.  That is, I want to find each occurrence of {if, elseif, for, switch, while, etc.} which is <em>not</em> behind a comment "%".  </p>
  
  <p>How?</p>
  
  <hr>
  
  <p><em>examples</em></p>
  
  <p>In <code>if(x &gt; 50)</code> match <em>if</em>.</p>
  
  <p>In <code>func(x) % What do I tell my boss if this doesn't work?</code> don't match <em>if</em>.</p>
  
  <hr>
  
  <p><em>Update</em></p>
  
  <p>Justin 'jjnguy' Nelson came with an answer that worked using basic regex.  (Thanks Justin)  However I had anticipated the solution requiring regex <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">lookaround</a>.  Does anyone have a solution that uses lookaround?  I'm having trouble getting my attempts to work.</p>