js去除字符串左右两端空格

运用正则去除空格:

//去左空格;
function lefttrim(s){
    return s.replace(/(^s*)/g, "");
}
//去右空格;
function righttrim(s){
    return s.replace(/(s*$)/g, "");
}
//去左右空格;
function trim(s){
    return s.replace(/(^s*)|(s*$)/g, "");
}

原文地址:https://www.cnblogs.com/liu-heng/p/6780235.html