var removStr = new String();
removStr = "some data with whitespaces, tabs, newlines etc..";
removStr.replace(/\B\s\B|[\n\r\t]/g,'');
Use a regular expressino like this. This will remove all new line chars, whitespaces, tabs etc..with a space.
Like this you can specify all your special chars.