Home > Web Front-end > JS Tutorial > body text

使用javascript过滤html的字符串(注释标记法)_javascript技巧

WBOY
Release: 2016-05-16 17:29:42
Original
952 people have browsed it
复制代码 代码如下:

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 = '000001234567111111890222228908903';
        var result = DeleteHtmlFromStartToEnd(str, '', '');
        alert(result);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!