trim·
Sunny-117 opened this issue · comments
Sunny commented
正则写就可以
return str.replace(/(^\s+)|(\s+$)/g,'')//将前空格和后空格替换为空
kangkang123269 commented
function myTrim(str) {
return str.replace(/^\s+|\s+$/g, '');
}
beary commented
String.prototype.myTrim = function() {
return this.replace(/(^\s+) | (\s+$)/g, "");
}