xxxxxxxxxx
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
xxxxxxxxxx
const str = "Hello, World! ";
const removedWhiteSpace = str.replace(/\s/g, "");
console.log(removedWhiteSpace); // Output: "Hello,World!"
xxxxxxxxxx
const str = " remove whitespace from string ";
const result = str.replace(/\s/g, "");
console.log(result);
xxxxxxxxxx
var msg = "Error= No connection.\n Verify Network.";
var umsg = msg.trim().replace(/\s/g,'');
xxxxxxxxxx
const str3 = " Hellow World! "
const str3Res = str3.trim() //"Hellow World!"