title: Javascript string replace of dots (.) within filenames
body: <p>I'm trying to parse and amend some html (as a string) using javascript and in this html, there are references (like img src or css backgrounds) to filenames which contain full stops/periods/dots/.</p>
  
  <p>e.g.</p>
  
  <pre><code>&lt;img src="../images/filename.01.png"&gt; &lt;img src="../images/filename.02.png"&gt;
  &lt;div style="background:url(../images/file.name.with.more.dots.gif)"&gt;
  </code></pre>
  
  <p>I've tried, struggled and failed to come up with a neat regex to allow me to parse this string and spit it back out without the dots in those filenames, e.g.</p>
  
  <pre><code>&lt;img src="../images/filename01.png"/&gt; &lt;img src="../images/filename02.png"/&gt;
  &lt;div style="background:url(../images/filenamewithmoredots.gif)"&gt;
  </code></pre>
  
  <p>I only want to affect the image filenames, and obviously I want to leave the filetype alone.</p>
  
  <p>A regex like:</p>
  
  <pre><code>/(.*)(?=(.gif|.png|.jpg|.jpeg))
  </code></pre>
  
  <p>allows me to match the main part of the filename and the extension seperately, but it also matches across the whole of the string, not just within the one filename I want.</p>
  
  <p>I have no control over the incoming html, I'm just consuming it.</p>
  
  <p>Help me please overflowers, you're my only hope!</p>