title: In javascript, how do I replace multiple strings with bold text without overriding the previous bold string?
body: <pre><code>function replaceKeys(inputString, keys){
  
      for (var i = 0; i &lt; keys.length; i++) {
                  var t = keys[i];
                  if (t) inputString= inputString.replace(new RegExp(t, 'gi'), '&lt;strong&gt;' + t + '&lt;/strong&gt;');
              }
              return s;
  }  
  </code></pre>
  
  <p>With the javascript method above I have tried to bold all text in a given string, based on a list of "keys" or string parts.</p>
  
  <p><strong>Example inputs:</strong><br/>
  keys=["man", "str"]
  inputString="strong man"<br/>
  <strong>intended output</strong>:<br/>
  <strong>str</strong>ong <strong>man</strong></p>
  
  <p>Unfortunately the output is replacing the "str" parts of the strong tags too. Meaning the output becomes<br/></p>
  
  <p>&lt;<strong>str</strong>ong><strong>str</strong>strong>ong <strong>man</strong>.
  <br/>
  Is there a Regular expression or some other method so that I can ignore html tags in a string so it doesn't have weird behaviour like this?</p>