js去除空格或所有空格
function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } /**
*is_global
设置"g" 去除所有空格,设置其它只去除前后空格。
**/
function trim(str,is_global) { var result; result = str.replace(/(^\s+)|(\s+$)/g,""); if(is_global.toLowerCase()=="g") { result = result.replace(/\s/g,""); } return result; }