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

Revision 2 of this benchmark created on


Setup

var mystring = 'France national football team';

Test runner

Ready to run.

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

Revisions

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