regex test

Benchmark created on


Setup

const html = '<p><img src="hi" /><script /><img onload="c" /></p>'

const onlyAllowedTagsRegexString = /<(?!\/?(p|i|em|strong|a|li|ul|ol)(?=>|\s.*>))\/?.*?>/;
const onlyAllowedTagsRegex =  new RegExp(onlyAllowedTagsRegexString);

const noEventRegexString = /(<.+?)(?<=\s)on[a-z]+\s*=\s*(?:([\'"])(?!\2).+?\2|(?:\S+?\(.*?\)(?=[\s>])))(.*?>)/;
const noEventRegex = new RegExp(noEventRegexString);

Test runner

Ready to run.

Testing in
TestOps/sec
tags
const result = onlyAllowedTagsRegex.test(html);
ready
attributes
const result = noEventRegex.test(html);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.