javascript 을 사용 하여 html 문자열 필터 링(주석 표기 법)


function DeleteHtmlFromStartToEnd(str, begin, end) {
            str = str.replace(begin + end, "");
            if (str.indexOf(begin) == -1) {//
                return str;
            }
            var substr = str.substring(str.indexOf(begin) + begin.length, str.indexOf(end));
            str = str.replace(substr, "");
            return DeleteHtmlFromStartToEnd(str, begin, end);
        }
        var str = '00000<!--deleteBegin-->1234567<!--deleteEnd-->111111<!--deleteBegin-->890<!--deleteEnd-->22222<!--deleteBegin-->890<!--deleteEnd--><!--deleteBegin-->890<!--deleteEnd-->3';
        var result = DeleteHtmlFromStartToEnd(str, '<!--deleteBegin-->', '<!--deleteEnd-->');
        alert(result);

좋은 웹페이지 즐겨찾기