title: How to extract an ext from a filename having special chars in it-javascript
body: <p>I am trying to get a the extension from a filename. The filename could include special characters, "#,@,.,_,(),..etc)
  ex: </p>
  
  <pre><code>var file1 = "fake.der"
  var file2 = "fake.1.der"
  var file3 = "fake_test.3.der"
  </code></pre>
  
  <p>NOw In the above case I want to extract only the ext "der" from every filename.
  I tried:</p>
  
  <pre><code>file1.split(".")[1] //works fine
  file2.split(".")[1] // gives me 1 -incorrect but file2.split(".")[2] gives correct result
  file3.split(".")[1] //gives 3-incorrect.
  </code></pre>
  
  <p>since filename could vary, I dont kinda want to make it the <code>.split(".")[1]</code> static, by changing it to <code>.split(".")[2]</code> for other filenames and so on..
  HOw can I make sure that regardless of how many dots present in the filename, I'll always get the extension only as o/p, is there a better appraoch?
  Thanks!</p>