Replace & Trim > script

본문 바로가기
사이트 내 전체검색

script

Replace & Trim

페이지 정보

작성자 서방님 댓글 0건 조회 190회 작성일 07-08-08 10:32

본문

// 모든 문자열 Replace
// var str = 문자열.replaceAll("a", "1");  // 문자열 내에서 'a'를 찾아 전부 '1'로 바꾸라는 의미

 

String.prototype.trim = function()
    {
      return this.replace(/(^s*)|(s*$)/gi, "");
    }

    String.prototype.replaceAll = function(str1, str2)
    {
      var temp_str = "";

      if (this.trim() != "" && str1 != str2)
      {
        temp_str = this.trim();

        while (temp_str.indexOf(str1) > -1)
        {
          temp_str = temp_str.replace(str1, str2);
        }
      }

      return temp_str;
    }

-----------------------------  or only Trim  -----------------------

//Trim

function Trim(STRING){
    STRING = LTrim(STRING);
    return RTrim(STRING);
}

 

function RTrim(STRING){
    while(STRING.charAt((STRING.length -1))==" "){
    STRING = STRING.substring(0,STRING.length-1);
}
return STRING;
}


function LTrim(STRING){
    while(STRING.charAt(0)==" "){
    STRING = STRING.replace(STRING.charAt(0),"");
}
return STRING;
}

 

댓글목록

등록된 댓글이 없습니다.

Total 846건 40 페이지
script 목록
번호 제목 글쓴이 조회 날짜
261 서방님 86 08-08
260 서방님 102 08-08
259 서방님 137 08-08
258 서방님 103 08-08
257 서방님 156 08-08
256 서방님 81 08-08
255 서방님 430 08-08
254 서방님 326 08-08
253 서방님 80 08-08
252 서방님 190 08-08
열람중 서방님 191 08-08
250 서방님 79 08-08
249 서방님 147 08-08
248 서방님 203 08-08
247 서방님 163 08-08
게시물 검색

회원로그인

접속자집계

오늘
27
어제
302
최대
1,347
전체
155,088
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.