= str.replace(begin end, ""); if (str.indexOf(begin) == -1) {//没找到 return str; } str = 。 substring(str.indexOf(begin) begin.length, str.indexOf(end)); str = str.replace(substr, ""); return DeleteHtmlFromStartToEnd(str, begin, end); } var str = '0000012345671111118902222 2< ;!--deleteBegin-->890>8903'; var result = DeleteHtmlFromStartToEnd( str, '', ''); alert(result);