Oh my god LMAO wth was I thinking haha. Short answer: I wasn't
Edit nope, your last version of escaping \E doesn't work try on $countcs(\e,\e), that's why I decided to go for binvars, it's surprisingly more work than you'd originally expect, huh?
After changing it to the cs version of $replace, it looks like we nailed it now lol.