UNPKG

ice.fo.utils

Version:

13 lines (11 loc) 426 B
/* eslint-disable vue/max-len */ import escapeRegExp from './escapeRegExp'; /** * Ex: replaceAll("find text to replace with text", "text", "Nikochin") => "find Nikochin to replace with Nikochin" * @param {*} text String input * @param {*} find String to find * @param {*} by String to replace with */ export default function replaceAll(text, find, by) { return text.replace(new RegExp(escapeRegExp(find), 'g'), by); }