[펌]replaceAll 함수 작성 본문

[PL]/Java Script

[펌]replaceAll 함수 작성

객과 함께. 2011. 12. 30. 01:20

        function replaceAll(value1, value2, value3) {

            while(1){
                if(value1.indexOf(value2) != -1){

                    value1 = value1.replace(value2, value3);
//                    //=======================================
                    if (value1.indexOf("V11") >= 0 || value1.indexOf("R11") >= 0) {

                        var tempval = value1.split(";");

                        for (var i = 0; i < 8; i += 2) {

                            if (tempval[i] == "V11" || tempval[i] == "R11") {

                                var temp = tempval[i];

                                var v3length = value3.length;

                                tempval[i] = temp.substr(0, v3length);

                            } else {
                                                       
                                    if (tempval[i].lastIndexOf(value2 , tempval.length) != -1) {

                                            tempval[i] = tempval[i].replace(value2 , value3);
                                    }
                            }
                         }
                            value1 = tempval;

                            break;
                    } 

                   }else{
                    break;
                }
            }
            return value1;
        }

 

어느 분께서 작성 하신 것을 약간 수정 하여하였습니다. 

 

'[PL] > Java Script' 카테고리의 다른 글

sms 글자수 제한하기 예제  (0) 2011.12.21
날자 관련 functin(2)  (0) 2011.05.21
날자 관련 function예제  (0) 2011.05.21
FOR 문 예제 (2)  (0) 2011.05.16
for 예문  (0) 2011.05.16