lm.data.LString类

      工作日记 2004-10-20 14:48:00
参考了THOR的data.TString,增加了对全角空格的删除!
//String的扩展类LString
class lm.data.LString extends String {
    function LString(string) {
        super(string);
    }
    //从此实例的开始移除数组中指定的一组空格的所有匹配项。
    function TrimStart(Void):LString {
        var index:Number = 0;
        while (index<length) {
            if (this.charCodeAt(index) != 0x20 && this.charCodeAt(index) != 0x3000) {
                break;
            }
            index++;
        }
        return new lm.data.LString(this.substr(index));
    }
    //从此实例的结尾移除数组中指定的一组空格的所有匹配项。
    function TrimEnd(Void):LString {
        var index:Number = length-1;
        while (index>=0) {
            if (this.charCodeAt(index) != 0x20 && this.charCodeAt(index) != 0x3000) {
                trace(index);
                break;
            }
            index--;
        }
        return new lm.data.LString(this.substr(0, index+1));
    }
    //从此实例的开始位置和末尾移除一组空格的所有匹配项。
    function Trim(Void) {
        return this.TrimStart().TrimEnd();
    }
}
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}