If you have XSJS as part of your solution, you could do this with a simple regex replace.
The below example shows how to do this:
var allowed ="A-Za-z"; // Only letters allowed
var rx = new RegExp("[^" + allowed + "]","gi");
var str ='HelloWorld1234!@#$%^';
var newstr = str.replace(rx,' ');
console.log(newstr); // returns "HelloWorld "