\s vs \s+ (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var str = '  A   B    C D    E   F GH I J    K     L M NOP Q  R   S TUVW XY  Z';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
\s
str.replace(/\s/g, '');
ready
\s+
str.replace(/\s+/g, '');
ready
\w\S*/g
str.replace(/\w\S*/g, function(txt) {
  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
ready

Revisions

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