regex vs lastindexof (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
lastindexof + substr
var name = "myinput[something][etc]";
var index = name.lastIndexOf('[');
var last = name.substr(index + 1, name.length - index - 2);
ready
regex
var s = 'myinput[something][etc]',
    re = /\[([^\]]*)\]$/,
    text = re.exec(s)[1];
ready

Revisions

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