title: jQuery, Get filename without the extension and then replace string
body: <p>I have this code to get the file extension:</p>
  
  <pre><code>filename1 = "a.crudely_formed.document_name.jpg"         
  var fileExtension = filename1.substring(filename1.lastIndexOf('.')); 
  </code></pre>
  
  <p>Now I need to only get the filename, without the extension. As you can see in the example file names can be wildly named by the users, that's why I have to use the lastIndexOf() method.
  I've searched for a method of doing this, but I found nothing.</p>
  
  <p>Additionally, when I have the filename (without the extension) I need something similiar to this</p>
  
  <pre><code>$filename = strtolower(str_replace(array('  ', ' '), '-', preg_replace('/[^a-zA-Z0-9 s]/', '', trim($filename))));
  </code></pre>
  
  <p>Above basically means, replace all spaces with dashes and only allow a-z and A-Z characters and all numbers. In the example above for example åöä is replaced by aoa.</p>
  
  <p>Any suggestions on how to do this in jQuery?</p>