Javascript: Escape regex / String replace all

Date: 2019-01-16
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string

const replaceAll = (str, find, replace) => (`${str}`).replace(new RegExp(escapeRegExp(find), 'g'), replace);

17820cookie-checkJavascript: Escape regex / String replace all