去除空格

function trim(str) {
    // 去除头和尾
    return str.replace(/^[" "||" "]*/,"").replace(/[" "|" "]*$/,"");
    //去除所有空格
    return str.replace(/\s/g,'');
    //去除右边所有空格
    return str.replace(/(\s*$)/g,"");
}