Use this for your replacement code fixes(In some cases, the result of the replacement is incorrect)Your original code was starting the search every time at the beginning of the string. this will prevent that.
int ci
for i 0 a.len
,sel i
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}")
,,case 1
,,ci=_s.findreplace(a[0 i] F"{e4}" 4 "" ci+e3.len)
,,case 2
,,ci=_s.findreplace(a[0 i] F"{e5}" 4 "" ci+e4.len)
,,case 3
,,ci=_s.findreplace(a[0 i] F"{e6}" 4 "" ci+e5.len)
,,case 4
,,ci=_s.findreplace(a[0 i] F"{e7}" 4 "" ci+e6.len)
,,case 5
,,ci=_s.findreplace(a[0 i] F"{e8}" 4 "" ci+e7.len)
,,case 6
,,ci=_s.findreplace(a[0 i] F"{e9}" 4 "" ci+e8.len)
,,case 7
,,ci=_s.findreplace(a[0 i] F"{e10}" 4 "" ci+e9.len)
,,case 8
,,ci=_s.findreplace(a[0 i] F"{e11}" 4 "" ci+e10.len)
,,case 9
,,ci=_s.findreplace(a[0 i] F"{e12}" 4 "" ci+e11.len)