JSFiddle - React, Tailwind, and code Playground
HTML
<script type="text/javascript">
function test(string) {
var match = /([\s"']+on\w+)\s*=/i.test(string);
return match ? 'match :(' : 'bypass :)';
}
var s=test('<body onload="alert(1)">');
alert(s);
</script>