使用javascript过滤html的字符串(注释标记法)_javascript技巧
程序员文章站
2022-05-18 12:31:39
...
复制代码 代码如下:
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);