JS 删除左右的空格

function trim(str){
return str.replace(/(^\s*)|(\s*$)/g, “”);
}