通过正则表达式:
let trim = function(string) {
return string.replace(/(^s*)|(s*$)/g, "");
}
可将该方法加入String属性中:
String.prototype.trim=function(){
return this.replace(/(^s*)|(s*$)/g, "");
}
通过正则表达式:
let trim = function(string) {
return string.replace(/(^s*)|(s*$)/g, "");
}
可将该方法加入String属性中:
String.prototype.trim=function(){
return this.replace(/(^s*)|(s*$)/g, "");
}