!!! JS
一、左空格
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;
}
二、
去除所有空格: str = str.replace(/s+/g,""); 去除两头空格: str = str.replace(/^s+|s+$/g,""); 去除空格(TimeSheet用过) arg0=arg0.replace(/s+$|^s+/g,"");
去除左空格: str=str.replace( /^s*/, ''); 去除右空格: str=str.replace(/(s*$)/g, "");
三、左边空格
function trim(str){
return str.replace(/^(s|xA0)+|(s|xA0)+$/g, '');
}
!!!-JQ
function Trim(str)
{
return str.replace(/(^s*)|(s*$)/g, "");
}