I want to replace all occurrences of white space characters (space, tab, newline) in JavaScript. How to do so?
I tried:
str.replace(/ /gi, \"X\
If you use
str.replace(/\s/g, "");
it replaces all whitespaces. For example:
var str = "hello my world"; str.replace(/\s/g, "") //the result will be "hellomyworld"