Getting first space-delineated character segment

Benchmark created by Will Nelson on


Setup

const string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam semper at erat ut aliquam.";
  const regex = /^[^\s]+/;

Test runner

Ready to run.

Testing in
TestOps/sec
Array methods
const word = string.split(" ")[0];
ready
Regex
const word = string.match(regex, '')[0];
ready
Regex (newly constructed)
const word = /^[^\s]+/.exec(string)[0];
ready

Revisions

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

  • Revision 1: published by Will Nelson on