AS支除兩邊的空格
/***************Public Function******************/
function LTrim(str:String):String {
var _s:String = str;
var _len:Number = _s.length;
var _char:String;
var i:Number = -1;
while (++i<_len) {
_char = _s.substr(i, 1);
if (_char != " " && _char != "\n" && _char != "\f" && _char != "\r" && _char != "\t") {
return _s.substr(i, _len-i);
}
}
}
function RTrim(str:String):String {
var _s:String = str;
var _len:Number = _s.length;
var _char:String;
var i:Number = _len;
while (--i>0) {
_char = _s.substr(i, 1);
if (_char != " " && _char != "\n" && _char != "\f" && _char != "\r" && _char != "\t") {
return _s.substr(0, ++i);
}
}
}
function Trim(str:String):String {
return LTrim(RTrim(str));
}
申明
非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!
博文欢迎转载,但请给出原文连接。