title: Javascript regex for validating filenames
body: <p>I have a regexp to validate file names. Here is it:</p>
  
  <pre><code>/[0-9a-zA-Z\^\&amp;\'\@\{\}\[\]\,\$\=\!\-\#\(\)\.\%\+\~\_ ]+$/
  </code></pre>
  
  <p>It should allow file names like this:</p>
  
  <pre><code>aaa
  aaa.ext
  a#
  A9#.ext
  </code></pre>
  
  <p>The following characters are not allowed <code>\ / : * ? \" &lt; &gt; |</code></p>
  
  <p>The problem is that file names like <code>*.txt</code> or <code>/\kk</code> passes the validation. I am doing validation with keyup event. So when I put one extra character after not allowed one it shows that everything is correct.</p>