I am trying to replace all occurrences of a value in a string with another value
what i still
var result = "Cooker Works"
var searchterm = "cooker wor";
searchterm.split(" ").forEach(function (item) {
result = result.replace(new RegExp(item, 'g'), "<strong>" + item + "</strong>");
});
console.log(result)
Run codeHide resultAs a result, I should look like
result = "<strong>Cooker</strong> <strong>Wor</strong>s";
I'm having trouble processing the case. Is there a way to ignore this and still get the result after
source
share