“JavaScript String trim ()” Code-Antworten

JavaScript -Trim

var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removed
Grepper

JavaScript String trim ()

let text1 = "      Hello World!      ";
let text2 = text1.trim();
naly moslih

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!
Tiny Coders

Ähnliche Antworten wie “JavaScript String trim ()”

Fragen ähnlich wie “JavaScript String trim ()”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen