title: Javascript Regex - add only a character to matched string
body: <p>I am trying to create a JS regex that matches a a string inside a given piece of code by it's beggining and ending and then only adds one character to that matched string.</p>
  <p>Please see below what I mean:</p>
  <p><strong>Imagine that I supply the following code:</strong></p>
  <pre><code>&lt;div&gt;
      &lt;p&gt;This is just some random text&lt;/p&gt;
      &lt;a href=&quot;https://somerandomsrc.com&quot;&gt;
          &lt;img src=&quot;https://somerandomsrc.com&quot; alt=&quot;random image&quot;&gt;
      &lt;/a&gt;
      &lt;img src=&quot;https://someotherrandomsrc.com&quot; alt=&quot;another random image&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>What I need to do is to have the script finding all instances of <code>&lt;img&gt;</code> and add a closing slash to the <code>&lt;img&gt;</code> elements so I would have something like this:</p>
  <pre><code>&lt;div&gt;
      &lt;p&gt;This is just some random text&lt;/p&gt;
      &lt;a href=&quot;https://somerandomsrc.com&quot;&gt;
          &lt;img src=&quot;https://somerandomsrc.com&quot; alt=&quot;random image&quot; /&gt;
      &lt;/a&gt;
      &lt;img src=&quot;https://someotherrandomsrc.com&quot; alt=&quot;another random image&quot; /&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Any help will be appreciated.</p>
  <p>Regards,
  T</p>