title: Complicated Javascript Reg Exp
body: <p>I've searched the previous questions about Reg Exp's but didn't find the help I need. I am rather a beginner in regular expressions and need a Javascript reg exp that limits a valid <em>filename</em> to the following:</p>
  
  <ul>
  <li>Allow only <code>A-Za-z0-9_-.</code> (<em>alphanumeric</em>, <em>underscore</em>, <em>hyphen</em>, <em>dot</em>)</li>
  <li>However, <em>filename</em> <strong>cannot start</strong> with a <em>hyphen</em> or <em>dot</em> </li>
  <li><em>Filename</em> <strong>cannot end</strong> with a <em>dot</em></li>
  <li>Only <strong>single</strong> <em>dot</em>s in <em>filename</em>, no <code>..</code></li>
  <li><strong>No</strong> <em>space</em>s</li>
  <li>Maximum length: <strong>255</strong></li>
  </ul>
  
  <p>I appreciate any assistance with this. Also, any thoughts about proper filenames is welcome. I believe the aforementioned requirements will serve me, but I can always hear more thoughts on the subject. I am creating a web-based application where people can upload documents. I'd prefer to just create universal filename limits and not be concerned with OS type. Thanks!</p>