title: Stripping out characters that aren't a-zA-Z0-9, _ and - from PHP strings
body: <p>I want to stop out all characters that do NOT match this regex pattern: <code>[a-zA-Z0-9_-]</code>.</p>
  
  <p>Usually I would do this:</p>
  
  <pre><code>preg_replace("[a-zA-Z0-9_-]", "", $var);
  </code></pre>
  
  <p>but obviously this has the oposite effect to what I want. Is there a NOT in regex? How can I get this to strip out any characters that do not match the pattern?</p>
  
  <p>Thanks.</p>