title: Replace a string word with empty space with js
body: <p>I have the following string:</p>
  
  <pre><code>var string = "Deluxe 3 Bed  Private"
  </code></pre>
  
  <p>and the following code to replace the "Private" word with an empty space:</p>
  
  <pre><code>var rooms = ["Basic", "Standard", "Superior", "Deluxe", "Private"];
  //var room = "room";
  vwo_$(document).ready(function(){
  
    WRI.eventBus.on('ui:microsite:availabilityStore:refresh', function(){
      var roomName = $(".roomnamelink");
      roomName.each(function(){
        for (var i = 0; i &lt; rooms.length; i++) {
          var pattern = "[^\s]" + rooms[i];
          var regex = new RegExp(pattern);
          string = string .replace(regex, " ");
        }
      });
    })
  </code></pre>
  
  <p>but my regex is probably wrong.</p>
  
  <p>If the word "Private" is found in the string I want that replaced with an empty space.</p>
  
  <pre><code>var string = "Deluxe 3 Bed"
  </code></pre>