0
Q:

remove spaces in a string js

str.replace(/\s+/g, '')
6
.replace(/ /g,'')
1
const removeSpaces = str => str.replace(/\s/g, '');

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'
1
str = str.replace(/\s/g, '');
0
string.split(" ").join("")
0
var str = "       Hello World!        ";
alert(str.trim());
5
str = str.trim();
1
var str = '/var/www/site/Brand new document.docx';

document.write( str.replace(/\s/g, '') );
0
var puzzle1=myTrim($("#puzzleinput").val());
            function myTrim(x) {
              return x.replace(/^\s+|\s+$/gm,'');
            }
0

New to Communities?

Join the community