how to replace multiple words using javascript replace() function?
<p>here is my code:</p>

<pre><code>        var keys = keyword.split(' ');
        //alert(keys);
        for(var i=0; i&lt;keys.length; i++)
            {
            var re = new RegExp(keys[i], "gi");
            var NewString = oldvar.replace(re, '&lt;span style="background-color:#FFFF00"&gt;'+keys[i]+'&lt;/span&gt;');
            document.getElementById("wordlist").innerHTML=NewString;
            alert(keys[i]);
            }
</code></pre>

<p>but here if I put a string "a b"; its split two words "a" and "b"
and this replace funtion replace "a" but when it get "b" it overrite and only replace "b".
but I want to hilight both "a" and "b".
how to solve this?
I got another problem . If I replace/highlight it then it replace all "a" and "b" of HTML tag. so, how to prevent to replace those html tag. but also when I display the whole text I need all html tag</p>
