title: Javascript replace dynamic text in string
body: <p>If i have a string as follows:</p>
  
  <pre><code>http:/mydomain.com/index.php/this/is/an/amazing/url/param/560/
  </code></pre>
  
  <p>and i want to replace the value of 560, what is the way to do this.</p>
  
  <p>Would a regex or string function be best used here and if so what would that be since the value can be different.</p>
  
  <p>i.e.</p>
  
  <p>the value can be anything:</p>
  
  <pre><code>http:/mydomain.com/index.php/this/is/an/amazing/url/param/120/
  http:/mydomain.com/index.php/this/is/an/amazing/url/param/200/
  </code></pre>
  
  <p>also the trailing slash may be missing i.e.</p>
  
  <pre><code>http:/mydomain.com/index.php/this/is/an/amazing/url/param/560
  </code></pre>