Skip to content

Instantly share code, notes, and snippets.

@island205
Last active August 29, 2015 14:06
Show Gist options
  • Save island205/0d36e6958122cf4ed04e to your computer and use it in GitHub Desktop.
Save island205/0d36e6958122cf4ed04e to your computer and use it in GitHub Desktop.
stripCommentTag
var STRIP_COMMENT_TAG_REGEXP, end, start, stripCommentTag, testStringA, testStringB;
STRIP_COMMENT_TAG_REGEXP = /<!--(.|\s)*?-->/gm;
stripCommentTag = function(html) {
return html.replace(STRIP_COMMENT_TAG_REGEXP, "");
};
testStringA = '<!-- -->';
testStringB = '<!-- ';
console.log('A', testStringA, testStringA.length);
start = new Date;
console.log(stripCommentTag(testStringA));
end = new Date;
console.log('cost', end.getTime() - start.getTime());
console.log('B', testStringB, testStringB.length);
start = new Date;
console.log(stripCommentTag(testStringB));
end = new Date;
console.log('cost', end.getTime() - start.getTime());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment