I want to replace all the occurrences of a particular word in the web page using javascript.
Sample Sentence = "Hi Guys, I have a lot of things. The things are good. They are beautiful-things. Look at /home/things.html"
I am using
document.body.innerHTML =
document.body.innerHTML.replace(/\bthings\b/g, function (x) {
return 'OBJECTS';
});
But this replaced like this
Hi Guys, I have a lot of OBJECTS. The OBJECTS are good. They are beautiful-OBJECTS. Look at /home/OBJECTS.html
I want to replace only whole words. Not (beautiful-things), (/home/things.html) should not be replaced. I want to replace only (things).
thingsdoesn't appear in the HTML parts (eg. class names)...innerHTML