.replace() vs. .split().join() vs .replaceAll() (v3)

Revision 3 of this benchmark created on


Setup

var mystring = '<a href="http://www.somewhere.net">http://www.somewhere.net</a>';

Test runner

Ready to run.

Testing in
TestOps/sec
.replace(/a href/g,'a target=_blank href')
result = mystring.replace(/a href/g,'a target=_blank href')
ready
.replace(new RegExp("a href","gm")," ")
result = mystring.replace(new RegExp("a href","gm"),"target=_blank href");
ready
.split('a href').join('a target=_blank href')
result = mystring.split('a href').join('a target=_blank href');
ready

Revisions

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