title: get string between two strings using jquery
body: <p>If I have this HTML</p>
  
  <pre><code>&lt;div class="comment-body"&gt;
  [img]http://topnews.net.nz/images/YouTube-3.jpg[/img] random text here
  &lt;/div&gt;
  
  &lt;div class="comment-body"&gt;
  [img]http://blog.brightcove.com/sites/all/uploads/FACEBOOK%20ICON.png[/img] random text here
  &lt;/div&gt;
  </code></pre>
  
  <p>how using jquery can I extract the value between <code>[img]</code> and <code>[/img]</code> and set it as a variable <code>data-src2=""</code> within an <code>&lt;img&gt;</code> element giving</p>
  
  <pre><code>&lt;div class="comment-body"&gt;
  &lt;img src="samesrc" class="commentimg" data-src2="http://topnews.net.nz/images/YouTube-3.jpg"/&gt; random text here
  &lt;/div&gt;
  
  &lt;div class="comment-body"&gt;
  &lt;img src="samesrc" class="commentimg" data-src2="http://blog.brightcove.com/sites/all/uploads/FACEBOOK%20ICON.png"/&gt; random text here
  &lt;/div&gt;
  </code></pre>
  
  <p>I don't have anything to give for what I have tried as I don't have a clue how to extract the value between <code>[img]</code> and <code>[/img]</code></p>
  
  <p>but overall <strong><a href="http://jsfiddle.net/yusaf/zy5j8/35/" rel="nofollow">THIS</a></strong> is what I'm trying to achieve if it doesn't make sense!</p>