google chrome - javascript replace is replacing nested words -


i creating google chrome extension messes words on whatever website reading, having trouble section of code specifically.

if(math.random() > 0.0){document.body.innerhtml = document.body.innerhtml.replace(/he/g, "it");} 

unfortunately working on word inside inside another. example: when comes across word "the", turns 'he' it, unfortunately making says "tit". how can change code avoid this?

.replace(/\bhe\b/g, "it") 

\b matches word boundary, replace single word he, not he part of word


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -