diff --git a/test/alphabet b/test/alphabet index 86e2f3dd..c2cf3ef4 100755 --- a/test/alphabet +++ b/test/alphabet @@ -20,7 +20,7 @@ spawnSync('npx', ['webpack', '--mode', 'production', '--output', output, input]) let js = fs.readFileSync(output).toString() fs.unlinkSync(output) -let match = js.match(/[A-Za-z0-9-_]{30,}/) +let match = js.match(/[\w-]{30,}/) if (!match) { process.stderr.write(chalk.red('Alphabet was not found\n')) process.exit(1) diff --git a/test/alphabet-genetic b/test/alphabet-genetic index 2949d711..882845a9 100644 --- a/test/alphabet-genetic +++ b/test/alphabet-genetic @@ -19,7 +19,7 @@ spawnSync('npx', ['webpack', '--mode', 'production', '--output', output, input]) let js = fs.readFileSync(output).toString() fs.unlinkSync(output) -let match = js.match(/[A-Za-z0-9-_]{30,}/) +let match = js.match(/[\w-]{30,}/) if (!match) { process.stderr.write(chalk.red('Alphabet was not found\n')) process.exit(1) @@ -66,7 +66,7 @@ function addMissingCharacter (str, proto) { } function fitnessFunction (phenotype) { - let file = js.replace(/[A-Za-z0-9-_]{30,}/, phenotype.alphabet) + let file = js.replace(/[\w-]{30,}/, phenotype.alphabet) let size = gzipSize.sync(file) console.log(size, phenotype.alphabet) return -1 * size @@ -106,9 +106,9 @@ console.log( ) console.log(chalk.green( 'Size new string:', - gzipSize.sync(js.replace(/[A-Za-z0-9-_]{30,}/, best.alphabet)) + gzipSize.sync(js.replace(/[\w-]{30,}/, best.alphabet)) )) console.log(chalk.yellow( 'Size old string:', - gzipSize.sync(js.replace(/[A-Za-z0-9-_]{30,}/, firstPhenotype.alphabet))) + gzipSize.sync(js.replace(/[\w-]{30,}/, firstPhenotype.alphabet))) ) diff --git a/test/benchmark b/test/benchmark index 152513e6..a489846c 100755 --- a/test/benchmark +++ b/test/benchmark @@ -18,8 +18,8 @@ let suite = new benchmark.Suite() function formatNumber (number) { return String(number) - .replace(/\d\d\d$/, ',$&') - .replace(/^(\d)(\d\d\d)/, '$1,$2') + .replace(/\d{3}$/, ',$&') + .replace(/^(\d)(\d{3})/, '$1,$2') } suite