title: Regex - how to ignore strings starting with underscore
body: <p>I need to test this string to match anything not starting with an underscore:</p>
  
  <p><code>__$id0 = "foo"</code></p>
  
  <p>My approach was to match the string starting with an underscore, then making that match into a negative look-ahead and capturing the rest. </p>
  
  <p>Testing for the underscore works:</p>
  
  <p><code>(_.*?\s)</code> gives one hit: '<code>__$id0</code>'</p>
  
  <p>However, making this into a negative look-ahead does not have the desired effect:</p>
  
  <p><code>((?!_.*?\s).*?\s)</code> results in </p>
  
  <pre><code>MATCH 1
  1.  [2-7]   `$id0 `
  MATCH 2
  1.  [7-9]   `= `
  MATCH 3
  1.  [9-16]  `"lala"`
  </code></pre>
  
  <p>The underscores are stripped from the first string, but the string itself still is in the resultset. I want to exclude that first string completely, because it starts with <code>_</code>. </p>
  
  <p><strong>How can I exclude strings starting with <code>_</code>?</strong></p>
  
  <p>The result should be this:</p>
  
  <pre><code>MATCH 1
  1.  [7-9]   `= `
  MATCH 2
  1.  [9-16]  `"lala"`
  </code></pre>
  
  <p>(Source: <a href="https://www.regex101.com/r/cC2pV7/1" rel="nofollow">https://www.regex101.com/r/cC2pV7/1</a>)</p>