title: Replace only last number in Javascript
body: <p>I have a div with Class name "<strong>separator</strong>" which holds a URL with different paths, but there is one similarity in each URL. what i did is get the URL from that div and replace a specific parameter.</p>
  
  <p><strong>HTML Code:</strong></p>
  
  <pre><code>&lt;div class="separator"&gt;
  &lt;a href="http://www.mydomain.com/images/s1600/photo.jpg"&gt;&lt;img src="http://www.mydomain.com/images/s1600/photo.jpg" height="225" width="400" /&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Here is the JavaScript Code:</strong></p>
  
  <pre><code>var ImageSource = document.getElementsByClassName('separator')[0].getElementsByTagName('a')[0].href;
  ImageSource = ImageSource.replace("0", "0-d");
  </code></pre>
  
  <p>This code works fine, i only want to target the last <code>0</code> from <code>/s1600/</code> because when this value has 2 Zeros it outputs like this:</p>
  
  <pre><code>http://www.mydomain.com/images/s160-d0/photo.jpg
  </code></pre>
  
  <p><strong>Which should be</strong></p>
  
  <pre><code>http://www.mydomain.com/images/s1600-d/photo.jpg
  </code></pre>
  
  <p>Please suggest some solution... Thanks :)</p>