Replace a part of string using jQuery/JavaScript
<p>I have a variable as below</p>

<pre><code>var a = "Hi this is test. &lt;img src='http://www.test.com/img1.jpg'&gt; Test ends here";
</code></pre>

<p>I want to replace the <code>src</code> of image tag to some other image url lets say <code>http://www.test2.com/img2.jpg</code></p>

<p>So the output should be</p>

<pre><code>var b = "Hi this is test. &lt;img src='http://www.test2.com/img2.jpg'&gt; Test ends here";
</code></pre>

<p>Both the image path would be dynamic.</p>

<p>Please help.</p>
