Is there a JavaScript regular expression to remove all whitespace except newline?
This will work, even on \t
.
var newstr = s.replace(/ +?/g, '');
[^\S\r\n]+
Not a non-whitespace char, not \r
and not \n
; one or more instances.
This will work, even on \t
.
var newstr = s.replace(/ +?/g, '');
[^\S\r\n]+
Not a non-whitespace char, not \r
and not \n
; one or more instances.