!!! 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, ""); 

     }

相关文章:

  • 2022-02-03
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-07-14
  • 2021-09-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
相关资源
相似解决方案