title: javascript regex Numbers and letters only
body: <p>This should automatically remove characters NOT on my regex, but if I put in the string <code>asdf sd %$##$</code>, it doesnt remove anything, and if I put in this <code>#sdf%#</code>, it only removes the first character. I'm trying to make it remove any and all instances of those symbols/special characters (anything not on my regex), but its not working all the time. Thanks for any help:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function ohno(){
  var pattern = new RegExp("[^a-zA-Z0-9]+");
  var str = "#sdf%#"; //"asdf sd %$##$" // Try both
  
  
  str = str.replace(pattern,' ');
  
  document.getElementById('msg').innerHTML = str;
  }  
  
    </code></pre>
  </div>
  </div>
  </p>