rsaburov,
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const createRegExp = str => new RegExp(escapeRegExp(str),'gm');
const replaceKeyword = (str, keyword, patern = '') => str.replace(createRegExp(keyword), patern)
let str = `123 Здравствуй мир
Здравствуй мир 123
123Здравствуй мир`;
let keyword = 'Здравствуй мир';
str = replaceKeyword(str, keyword);
alert(str)