I think the reason is that RegExp match()
is indeed slower than indexOf
You can check here.
From the above site only the code:
<script>
var str = "hello world!";
</script>
5,616,069 Ops/sec Using match time taken is ±3.05% 55% slower
12,306,269 Ops/sec Using indexOf() time taken is ±2.51% fastest