replace characters in string

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
short regex
"H e".replace(/\s/g,'');
short split and join
"H e".split(' ').join('');
long regex
"H e l l o W o r l d t h i s h a s s o m a n y s p a c e s".replace(/\s/g,'');
long split and join
"H e l l o W o r l d t h i s h a s s o m a n y s p a c e s".split(' ').join('');

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment