dynamic global value replacement in javascript
<pre><code>&lt;html&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;

var str="Welcome to Microsoft! ";
var val="Microsoft!";

document.write(str.replace('/'+val'+/gi', "W3Schools"));

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>this is not working, how to use val dynamically ?</p>
