Script Preparation code:
AخA
 
var strings = [
  'bbbb',
  'AAbb',
  'aaBB',
  'AAbb11',
  'aaBB11',
  '11aaBB',
  'aaAAbb',
  'aaaa'
];
Tests:
  • regexp

     
    const matches = strings.filter(s => /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d$@!%*#?&-_]{4,14}$/.test(s));
    if (matches.length !== 3) {
      throw 'invalid number of matches: ' + matches;
    }
  • many regexps

     
    const matches = strings.filter(s => {
      return /^[\w$@!%*#?&-]{4,14}$/.test(s) &&
             /[A-Z]/.test(s) &&
             /[a-z]/.test(s) &&
             /[0-9]/.test(s);
    });
    if (matches.length !== 3) {
      throw 'invalid number of matches: ' + matches;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    regexp
    many regexps

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36
Chrome 53 on Mac OS X 10.11.6
View result in a separate tab
Test name Executions per second
regexp 574183.2 Ops/sec
many regexps 295866.8 Ops/sec