Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript string trim()

let text = "       Hello World!        "; // output : Hello World!
let result = text.trim();
//Remove spaces with replace() using a regular expression:
let text = "       Hello World!        ";
let result = text.replace(/^s+|s+$/gm,''); // output : Hello World!
 
PREVIOUS NEXT
Tagged: #javascript #string
ADD COMMENT
Topic
Name
7+8 =