web前端面试题(二十)之 正则表达式清除字符串前后的空格?
function trim(str) {
if (str && typeof str === "string") {
// 去除前后空白符
return str.replace(/(^s*)|(s*)$/g,"");
}
}
function trim(str) {
if (str && typeof str === "string") {
// 去除前后空白符
return str.replace(/(^s*)|(s*)$/g,"");
}
}