LotusScript의 Trim 함수 많이 쓰시죠?
JavaScript에서도 가끔(?) 사용되는 함수입니다.

Trim~~
앞뒤 공백을 제거하고 중간에 겹쳐진 스페이스를 하나의 스페이스로...

---------------------------------------------------------------------------------------------------
function Trim(sValue)
{
        sValue = String(sValue);
        // 다중 공백 제거
        for( ; sValue.indexOf("  ") != -1 ; )
                sValue = sValue.replace( "  ", " " );
       
        // 앞 공백 제거
        if( sValue.indexOf(" ") == 0 )
                sValue = sValue.substring( 1, sValue.length );

        // 뒤 공백 제거
        if( sValue.lastIndexOf(" ") == sValue.length -1 )
                sValue = sValue.substring( 0, sValue.length-1 );

        return sValue;
}
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
2007/05/25 15:13 2007/05/25 15:13
Posted by 바라기

트랙백 주소 :: http://www.baragi.pe.kr/baragi/trackback/38

댓글을 달아 주세요

[로그인][오픈아이디란?]