// Prototype version
String.prototype.trim = function() {
return this.replace(/^s+|s+$/g, "");
};
// Stand alone version
function(str) {
return str.replace(/^s+|s+$/g, "");
};
Posted: March 20, 2023
Return to the snippets listing