xxxxxxxxxx
const str = " remove whitespace from string ";
const result = str.replace(/\s/g, "");
console.log(result);
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
let name = " John Doe ";
let trimmedName = name.trim(); // Output: "John Doe"
xxxxxxxxxx
var msg = "Error= No connection.\n Verify Network.";
var umsg = msg.trim().replace(/\s/g,'');
xxxxxxxxxx
const str = " Hello, World! ";
const trimmedStr = str.trim();
console.log(trimmedStr); // "Hello, World!"