str.replace(/s+/g, '')
const removeSpaces = str => str.replace(/s/g, '');
// Example
removeSpaces('hel lo wor ld'); // 'helloworld'
var a = b = " /var/www/site/Brand new document.docx ";
console.log( a.split(' ').join('') );
console.log( b.replace( /s/g, '') );
var str = " Hello World! ";
alert(str.trim());
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/s/g, '') );
str.replace(/s+/g, '') //Replace str with variable name you have string saved too.
var str = "470 ";
str.trim();
var puzzle1=myTrim($("#puzzleinput").val());
function myTrim(x) {
return x.replace(/^s+|s+$/gm,'');
}
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/s/g, '') );
Run code snippetHide results