Skip to content

Instantly share code, notes, and snippets.

@vsemozhetbyt
Created June 29, 2017 10:16
Show Gist options
  • Save vsemozhetbyt/548cc2b50e9d994dd79027b701e37ed5 to your computer and use it in GitHub Desktop.
Save vsemozhetbyt/548cc2b50e9d994dd79027b701e37ed5 to your computer and use it in GitHub Desktop.
'use strict';
const { writeFileSync } = require('fs');
const LAST_CODE_POINT = 0x10FFFF;
const RegExps = [/./u, /^(?!.)/, /\w/u, /\W/u, /\d/u, /\D/u, /\s/u, /\S/u, /\b/u, /\B/u];
let codePoint = 0;
let str;
let data = '';
while (codePoint <= LAST_CODE_POINT) {
str = String.fromCodePoint(codePoint);
data += `${codePoint} ${RegExps.filter(test).join(' ')}\n`;
codePoint++;
}
writeFileSync(
`code-points-vs-regexps.node.${process.versions.node}.V8.${process.versions.v8}.txt`,
data);
function test(re) { return re.test(str); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment