字符串方法去除左右空格 " 1 2 3 ".trim() // "1 2 3" 正则方法去除左右空格 " s f fd ".replace(/\s+/g, '') //"sffd" " s f fd ".replace(/(^\s+)|(\s+$)/g, '')//"s f fd" " s f fd ".replace(/^\s+/, "").replace(/\s+$/,"");