title: Remove illegal characters from a file name but leave spaces
body: <p>I have the following line of code to remove illegal characters from a file name:</p>
  
  <pre><code>str= str.replace(/([^a-z0-9]+)/gi, '-');
  </code></pre>
  
  <p>That works fine but it also removes the spaces, how can I only remove the illegal characters but leave the spaces?</p>