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 = " Some text ";
str.trim();
// str = "Some text"
str = str.trim();
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.
let text = "I love you"
text = text.replace( / +/g, '_') // replace with underscore ('_')
console.log(text) // I_love_you
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