SyntaxFix
Write A Post
Hire A Developer
Questions
That first line is pretty messed up. It only needs to be:
var cleanText = text.replace(/\xA0/g,' ');
That should be all you need.