JSFiddle - React, Tailwind, and code Playground
JavaScript
var wordToReplace = '買い手',
replacementWord = '[[BUYER]]',
text = 'Manage (買い手) information for the 買い手. The 買い手 will be an angry 買い手!';
function replaceWord(text, wordToReplace, replacementWord) {
var re = new RegExp('(^|\\s|\\(|\'|"|,|;)' + wordToReplace + '($|\\s|\\)|\\.|\'|"|!|,|;|\\?)', 'gi');
return text.replace(re, '$1' + replacementWord + '$2');
}
alert(replaceWord(text, wordToReplace, replacementWord));