JS去除字符串两端空格的简单实例
内容摘要
//去左空格;function ltrim(s){
return s.replace(/(^s*)/g, "");}//去右空格;function rtrim(s){return s.replace(/(s*$)/g, "");}//去左右空格;function trim(s){return
return s.replace(/(^s*)/g, "");}//去右空格;function rtrim(s){return s.replace(/(s*$)/g, "");}//去左右空格;function trim(s){return
文章正文
//去左空格;
function ltrim(s)
{
return s.replace(/(^s*)/g, "");
}
//去右空格;
function rtrim(s)
{
return s.replace(/(s*$)/g, "");
}
//去左右空格;
function trim(s){
return s.replace(/(^s*)|(s*$)/g, "");
}
代码注释