2018-02-09 06:29:29 +00:00
|
|
|
export function replaceAll (string, replacee, replacement) {
|
2018-08-20 02:03:26 +01:00
|
|
|
if (!string.length || !replacee.length) {
|
2018-01-22 06:46:27 +00:00
|
|
|
return string
|
|
|
|
}
|
|
|
|
let idx
|
|
|
|
let pos = 0
|
|
|
|
while (true) {
|
|
|
|
idx = string.indexOf(replacee, pos)
|
|
|
|
if (idx === -1) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
string = string.substring(0, idx) + replacement + string.substring(idx + replacee.length)
|
|
|
|
pos = idx + replacement.length
|
|
|
|
}
|
|
|
|
return string
|
2018-02-09 06:29:29 +00:00
|
|
|
}
|