0
Q:

javascript remove space from string

str.replace(/\s+/g, '')
6
.replace(/ /g,'')
1
var str = "  Some text ";
str.trim();
// str = "Some text"
9
string.split(" ").join("")
0
const removeSpaces = str => str.replace(/\s/g, '');

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

document.write( str.replace(/\s/g, '') );
0

New to Communities?

Join the community