2021-07-05 10:29:04 +00:00
|
|
|
/**
|
|
|
|
* This function replaces all text, no matter the case.
|
|
|
|
*
|
|
|
|
* See https://stackoverflow.com/a/7313467/10924593
|
|
|
|
*
|
|
|
|
* @parma str
|
|
|
|
* @param search
|
|
|
|
* @param replace
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2022-02-13 19:09:12 +00:00
|
|
|
export const replaceAll = (str: string, search: string, replace: string) => {
|
2021-07-19 09:18:22 +00:00
|
|
|
const esc = search.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
|
|
const reg = new RegExp(esc, 'ig')
|
|
|
|
return str.replace(reg, replace)
|
2021-07-05 10:29:04 +00:00
|
|
|
}
|