JSFiddle - React, Tailwind, and code Playground
JavaScript
var text = 'hi all! :)';
function replaceEmotion (text) {
var newText = text.replace(/:\)/g, '<img width="23" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQCp1ny3sdYH4gFBlHFLEpvJcIiMq1VtZE1SiAjoe8B4AoPqbXd">');
return newText;
}
document.body.innerHTML = replaceEmotion(text);