Dusty made a
great replacetext() function, but one of these should be hard-coded into the client and NPC-server in the next Graal release. It's a basic scripting function that almost all languages have.
The benefit of hard-coding it instead of using a scripted one like Dusty's is that it is more optimized and efficient, and you wouldn't have to add code to every script you want to have the function.