title: Find base name in URL in Javascript
body: <p>I want to extract the base name from a image URL in Javascript. Would somebody care to give me a a hand on the Regex?</p>
  
  <p>The rule would be:</p>
  
  <ul>
  <li><p>return everything right of the last <code>/</code> left of the last <code>.</code> </p>
  
  <p>www.domain.com/images/<strong>image.hires</strong>.jpg</p></li>
  <li><p>if no <code>.</code> is found, return the full base name
  www.domain.com/images/<strong>image_hi_res</strong></p></li>
  </ul>
  
  <p>I have a clumsy <code>/\/[^.]+\.[^.]+$/</code> but don't know how to make the <code>/</code> and the <code>.</code> optional and how to seek for the last <code>.</code> only. </p>
  
  <blockquote>
    <p>Cheers folks for all the great input, as always. I chose the one Regex that worked for me out of the box. </p>
  </blockquote>