string split+isInteger vs regex (v4)

Revision 4 of this benchmark created on


Setup

const text = 'Base.1.0.56745675467.PasswordChangeRequired';
const regex = new RegExp('^Base\\.\\d+\\.\\d+\\.\\d+.\\PasswordChangeRequired$');

Test runner

Ready to run.

Testing in
TestOps/sec
split
const words = text.split('.');

words[0] === 'Base' &&
!Number.isNaN(Number.parseInt(words[1])) &&
!Number.isNaN(Number.parseInt(words[2])) &&
!Number.isNaN(Number.parseInt(words[3])) &&
words[4] === 'PasswordChangeRequired'

ready
regex match
text.match(regex) !== null
ready

Revisions

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