Regex Performance Testing (v5)

Revision 5 of this benchmark created on


Description

How much faster is a precompiled regex vs a non-precompiled regex?

Setup

var HAS_HYPHEN_RE = /\S-\S/;
    
    myHtml = "<span>This is a test</span><div>Of a regex</div><p>test</p><em>test</em>";

Test runner

Ready to run.

Testing in
TestOps/sec
Precompiled Regex (Replace)
HAS_HYPHEN_RE.test(myHtml);
ready
Non-Precompiled Regex (Replace)
/\S-\S/.test(myHtml);
 
ready

Revisions

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