JSFiddle - React, Tailwind, and code Playground
HTML
<div id="result">...</div>
JavaScript
String.prototype.replaceAll = function (find, replace) {
var str = this;
return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
};
string = "hello$&. world";
string = string.replaceAll('hello$&.', 'hello');
$('#result').html(string);