JAVASCRIPT
remove spaces in a string js
javascript remove space from string
const removeSpaces = str => str.replace(/s/g, '');
// Example
removeSpaces('hel lo wor ld'); // 'helloworld'
Delete spaces in text in javascript
var a = b = " /var/www/site/Brand new document.docx ";
console.log( a.split(' ').join('') );
console.log( b.replace( /s/g, '') );
js remove space before string
var str = " Some text ";
str.trim();
// str = "Some text"
remove blank space javascript
str.replaceAll(/s/g,'')
.replace(/ /g,'')
js remove spaces
remove space from string javascript
var str = " Hello World! ";
alert(str.trim());
how to remove spaces from strings javascript
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/s/g, '') );
how to erase spaces from a string javascript
str.replace(/s+/g, '') //Replace str with variable name you have string saved too.
javascript remove space
let text = "I love you"
text = text.replace( / +/g, '_') // replace with underscore ('_')
console.log(text) // I_love_you
delete space from string javascript
var str = "470 ";
str.trim();
remove space from string javascript
var puzzle1=myTrim($("#puzzleinput").val());
function myTrim(x) {
return x.replace(/^s+|s+$/gm,'');
}
remove spaces from string javascript
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/s/g, '') );
Run code snippetHide results