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")
You want s
s
Matches a single white space character, including space, tab, form feed, line feed.
Equivalent to
[ f vu00a0u1680u2000-u200au2028u2029u202fu205fu3000ufeff]
in Firefox and [ f v] in IE.
[ f v]
str = str.replace(/s/g, "X");
1.4m articles
1.4m replys
5 comments
57.0k users