supprimer les espaces dans une chaîne js
str.replace(/\s+/g, '')
Dangerous Duck
str.replace(/\s+/g, '')
str = str.replace(/\s/g, '');
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
var name = "codepadding code ";
// remove all white spaces single or multiple spaces
var name = name.replace(/\s/g, '');
console.log(name)
//output
//mizanurrahmanmizan
str = str.trim();
const removeAllSpaces = (string) => {
const newText = string.replace(/\s+/g, "");
return newText
};
console.log(removeAllSpaces(" Hello World "));
//HelloWorld