I have the following string:
var string = "Deluxe 3 Bed Private"
and the following code to replace the "Private" word with an empty space:
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 < rooms.length; i++) {
var pattern = "[^\s]" + rooms[i];
var regex = new RegExp(pattern);
string = string .replace(regex, " ");
}
});
})
but my regex is probably wrong.
If the word "Private" is found in the string I want that replaced with an empty space.
var string = "Deluxe 3 Bed"