remove extra space in string js
newString = string.replace(/\s+/g,' ').trim();
remove extra space in string js
newString = string.replace(/\s+/g,' ').trim();
javascript remove all whitespaces
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
js method string remove extra spaces
const sentence = ' My string with a lot of Whitespace. '.replace(/\s+/g, ' ').trim()
// 'My string with a lot of Whitespace.'
remove whitespace with regex javascript
return str.replace(/\s/g, '');
remove extra spaces javascript
const removeExtraSpaces = (string) => {
const newText = string
.replace(/\s+/g, " ")
.replace(/^\s+|\s+$/g, "")
.replace(/ +(\W)/g, "$1");
return newText
};
console.log(removeExtraSpaces(" Hello World!"))
//Hello World!
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us