Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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!
Source by www.textbotonline.com #
 
PREVIOUS NEXT
Tagged: #remove #extra #spaces #javascript
ADD COMMENT
Topic
Name
1+8 =