asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
< script type = " text/javascript " >
function  lTrim(str)  {
   
if (str.charAt( 0 ) = = "   "
    str
= str.slice( 1 );
  
return  str.charAt( 0 ) = = "   " ? arguments.callee(str):str;
         }

function  rTrim(str)  {
  
if (str.charAt(str.length - 1 ) = = "   " )
   str
= str.slice( 0 ,str.length - 1 );
  
return  str.charAt(str.length - 1 ) = = "   " ? arguments.callee(str):str;
  }

function  Trim(str)  {
  
return  lTrim(rTrim(str));
 }

</ script >
当然用正则可能更好:
String.prototype.lTrim=function() {
  
this.replace(/^\s*/g,"");
      }

String.prototype.rTrim
=function() {
  
this.replace(/\s*$/g,"");
      }

String.prototype.Trim
=function() {
  
this.replace(/^\s*|\s*$/g,"");
      }
posted on 2006-07-15 09:59 汪杰 阅读(221) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 457963
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜