{"name":"re2","version":"1.24.1","keywords":["RegExp","RegEx","text processing","PCRE alternative"],"author":{"url":"https://lazutkin.com/","name":"Eugene Lazutkin","email":"eugene.lazutkin@gmail.com"},"license":"BSD-3-Clause","_id":"re2@1.24.1","maintainers":[{"name":"elazutkin","email":"eugene.lazutkin@gmail.com"}],"homepage":"https://github.com/uhop/node-re2","bugs":{"url":"https://github.com/uhop/node-re2/issues"},"dist":{"shasum":"4501a9d46dd8970eb580257c0160c18752c7f977","tarball":"http://registry-npm.ywwl.com/re2/download/re2-1.24.1.tgz","fileCount":1730,"integrity":"sha512-uRl9cLDKuobJQp+6lVz7E3AyVszubUJ0fqAMWout4ocUWTIFvdHgpqLwwMh/vuNGGGJGh2p2mJZJIQr9am9M/A==","signatures":[{"sig":"MEUCIQDDaRPQLyxoI44DixKsCHMw5Wu21LcP1u7B+MEOjK7huQIgYn1axoZdOVrAzwaIW/+5qY8x+HMZCeeIEt8oPJvkbp0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12343732,"size":2701836,"noattachment":false,"key":"/re2/-/re2-1.24.1.tgz"},"main":"re2.js","type":"commonjs","tape6":{"tests":["/tests/test-*.*js","/tests/test-*.*ts"]},"types":"re2.d.ts","github":"https://github.com/uhop/node-re2","engines":{"node":">=22"},"funding":"https://github.com/sponsors/uhop","gitHead":"1cbaf98c0875e3eacf54207924b8abd02105c237","scripts":{"lint":"prettier --check *.js *.ts tests/ bench/","test":"tape6 --flags FO","build":"node-gyp -j max build","clean":"node-gyp clean && node-gyp configure","build1":"node-gyp build","install":"install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || node-gyp -j max rebuild","rebuild":"node-gyp -j max rebuild","lint:fix":"prettier --write *.js *.ts tests/ bench/","rebuild1":"node-gyp rebuild","test:seq":"tape6-seq --flags FO","ts-check":"tsc --noEmit","build:dev":"node-gyp -j max build --debug","test:proc":"tape6-proc --flags FO","clean-build":"node-gyp clean","rebuild:dev":"node-gyp -j max rebuild --debug","verify-build":"node scripts/verify-build.js","save-to-github":"save-to-github-cache --artifact build/Release/re2.node"},"_npmUser":{"name":"elazutkin","email":"eugene.lazutkin@gmail.com"},"repository":{"url":"git+https://github.com/uhop/node-re2.git","type":"git"},"_npmVersion":"11.13.0","description":"Bindings for RE2: fast, safe alternative to backtracking regular expression engines.","directories":{},"_nodeVersion":"26.1.0","dependencies":{"nan":"^2.27.0","node-gyp":"^12.3.0","install-artifact-from-github":"^1.6.0"},"_hasShrinkwrap":false,"devDependencies":{"prettier":"^3.8.3","tape-six":"^1.9.0","typescript":"^6.0.3","@types/node":"^25.7.0","tape-six-proc":"^1.2.9","nano-benchmark":"^1.0.15"},"_npmOperationalInternal":{"tmp":"tmp/re2_1.24.1_1778629159027_0.7741678627821047","host":"s3://npm-registry-packages-npm-production"},"readme":"# node-re2 [![NPM version][npm-img]][npm-url]\n\n[npm-img]: https://img.shields.io/npm/v/re2.svg\n[npm-url]: https://npmjs.org/package/re2\n\nThis project provides Node.js bindings for [RE2](https://github.com/google/re2):\na fast, safe alternative to backtracking regular expression engines written by [Russ Cox](http://swtch.com/~rsc/) in C++.\nTo learn more about RE2, start with [Regular Expression Matching in the Wild](http://swtch.com/~rsc/regexp/regexp3.html). More resources are on his [Implementing Regular Expressions](http://swtch.com/~rsc/regexp/) page.\n\n`RE2`'s regular expression language is almost a superset of what `RegExp` provides\n(see [Syntax](https://github.com/google/re2/wiki/Syntax)),\nbut it lacks backreferences and lookahead assertions. See below for details.\n\n`RE2` always works in [Unicode mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) &mdash; character codes are interpreted as Unicode code points, not as binary values of UTF-16.\nSee `RE2.unicodeWarningLevel` below for details.\n\n`RE2` emulates standard `RegExp`, making it a practical drop-in replacement in most cases.\nIt also provides `String`-based regular expression methods. The constructor accepts `RegExp` directly, honoring all properties.\n\nIt can work with binary data directly &mdash; [Node.js Buffers](https://nodejs.org/api/buffer.html), typed arrays, `DataView`, `ArrayBuffer`, `SharedArrayBuffer` &mdash; reducing overhead and making processing of long files fast.\n\nThe project is a C++ addon built with [nan](https://github.com/nodejs/nan). It cannot be used in web browsers.\nAll documentation is in this README and in the [wiki](https://github.com/uhop/node-re2/wiki) &mdash; browse the [index](https://github.com/uhop/node-re2/wiki/Home), or [search it](https://uhop.github.io/wiki-search/app/?wiki=uhop/node-re2) by name.\n\n## Why use node-re2?\n\nThe built-in Node.js regular expression engine can run in exponential time with a special combination:\n - A vulnerable regular expression\n - \"Evil input\"\n\nThis can lead to what is known as a [Regular Expression Denial of Service (ReDoS)](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS).\nTo check if your regular expressions are vulnerable, try one of these projects:\n - [rxxr2](http://www.cs.bham.ac.uk/~hxt/research/rxxr2/)\n - [safe-regex](https://github.com/substack/safe-regex)\n\nNeither project is perfect.\n\nnode-re2 protects against ReDoS by evaluating patterns in `RE2` instead of the built-in regex engine.\n\nTo run the bundled benchmark (make sure node-re2 is built first):\n\n```bash\nnpx nano-bench bench/bad-pattern.mjs\n```\n\n## Standard features\n\n`RE2` objects are created just like `RegExp`:\n\n* [`new RE2(pattern[, flags])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)\n\nSupported flags: `g` (global), `i` (ignoreCase), `m` (multiline), `s` (dotAll), `u` (unicode, always on), `y` (sticky), `d` (hasIndices).\n\nSupported properties:\n\n* [`re2.lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)\n* [`re2.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global)\n* [`re2.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase)\n* [`re2.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline)\n* [`re2.dotAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll)\n* [`re2.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) &mdash; always `true`; see details below.\n* [`re2.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky)\n* [`re2.hasIndices`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices)\n* [`re2.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source)\n* [`re2.flags`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags)\n\nSupported methods:\n\n* [`re2.exec(str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)\n* [`re2.test(str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n* [`re2.toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString)\n\nWell-known symbol-based methods are supported (see [Symbols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)):\n\n* [`re2[Symbol.match](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match)\n* [`re2[Symbol.matchAll](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/matchAll)\n* [`re2[Symbol.search](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search)\n* [`re2[Symbol.replace](str, newSubStr|function)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace)\n* [`re2[Symbol.split](str[, limit])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)\n\nThis lets you use `RE2` instances on strings directly, just like `RegExp`:\n\n```js\nconst re = new RE2('1');\n'213'.match(re);        // [ '1', index: 1, input: '213' ]\n'213'.search(re);       // 1\n'213'.replace(re, '+'); // 2+3\n'213'.split(re);        // [ '2', '3' ]\n\nArray.from('2131'.matchAll(new RE2('1', 'g'))); // matchAll requires the g flag\n// [['1', index: 1, input: '2131'], ['1', index: 3, input: '2131']]\n```\n\n[Named groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group) are supported.\n\n## Extensions\n\n### Shortcut construction\n\n`RE2` can be created from a regular expression:\n\n```js\nconst re1 = new RE2(/ab*/ig); // from a RegExp object\nconst re2 = new RE2(re1);     // from another RE2 object\n```\n\n### `String` methods\n\n`RE2` provides the standard `String` regex methods with swapped receiver and argument:\n\n* `re2.match(str)`\n  * See [`str.match(regexp)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)\n* `re2.replace(str, newSubStr|function)`\n  * See [`str.replace(regexp, newSubStr|function)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)\n* `re2.search(str)`\n  * See [`str.search(regexp)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)\n* `re2.split(str[, limit])`\n  * See [`str.split(regexp[, limit])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\n\nThese methods are also available as well-known symbol-based methods for transparent use with ES6 string/regex machinery.\n\n### `Buffer` support\n\nMost methods accept binary objects instead of strings for direct UTF-8 processing:\n`Buffer`, any `TypedArray` (e.g., `Uint8Array`), `DataView`, `ArrayBuffer`, and `SharedArrayBuffer`\nare all read as raw UTF-8 bytes (views at their byte offset and length):\n\n* `re2.exec(buf)`\n* `re2.test(buf)`\n* `re2.match(buf)`\n* `re2.search(buf)`\n* `re2.split(buf[, limit])`\n* `re2.replace(buf, replacer)`\n\nPatterns, flags, and `replace()` replacement values can be binary objects too.\n\nDifferences from string-based versions:\n\n* All binary input is assumed to be encoded as [UTF-8](https://en.wikipedia.org/wiki/UTF-8)\n  (ASCII is a proper subset of UTF-8).\n* Results are `Buffer` objects for any binary input, even in composite objects. Convert with\n  [`buf.toString()`](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).\n  (`Buffer` is a `Uint8Array` subclass, so the results satisfy consumers expecting `Uint8Array`.)\n* All offsets and lengths are in bytes, not characters (each UTF-8 character occupies 1–4 bytes).\n  This lets you slice buffers directly without costly character-to-byte recalculations.\n* Writing to a `SharedArrayBuffer` concurrently while it is being matched yields unspecified\n  match results (reads are always kept in bounds).\n\nWhen `re2.replace()` is used with a replacer function, the replacer receives string arguments and character offsets by default. Set `useBuffers` to `true` on the function to receive byte offsets instead:\n\n```js\nfunction strReplacer(match, offset, input) {\n\t// typeof match == \"string\"\n\treturn \"<= \" + offset + \" characters|\";\n}\n\nRE2(\"б\").replace(\"абв\", strReplacer);\n// \"а<= 1 characters|в\"\n\nfunction bufReplacer(match, offset, input) {\n\t// typeof match == \"string\"\n\treturn \"<= \" + offset + \" bytes|\";\n}\nbufReplacer.useBuffers = true;\n\nRE2(\"б\").replace(\"абв\", bufReplacer);\n// \"а<= 2 bytes|в\"\n```\n\nThis works for both string and buffer inputs. Buffer input produces buffer output; string input produces string output.\n\n### `RE2.Set`\n\nUse `RE2.Set` when the same string must be tested against many patterns. It builds a single automaton and frequently beats running individual regular expressions one by one.\n\nWhile `test()` can be simulated by combining patterns with `|`, `match()` returns which patterns matched &mdash; something a single regular expression cannot do.\n\n* `new RE2.Set(patterns[, flagsOrOptions][, options])`\n  * `patterns` is any iterable of strings, binary objects (`Buffer`, `TypedArray`, `DataView`, `ArrayBuffer`, `SharedArrayBuffer`), `RegExp`, or `RE2` instances; flags (if provided) apply to the whole set.\n  * `flagsOrOptions` can be a string or binary object with standard flags (`i`, `m`, `s`, `u`, `g`, `y`, `d`).\n  * `options.anchor` can be `'unanchored'` (default), `'start'`, or `'both'`.\n  * `options.maxMem` is the DFA memory budget in bytes (positive integer). Default is 8 MiB &mdash; raise it to compile sets that would otherwise fail with `\"RE2.Set could not be compiled.\"`.\n* `set.test(str)` returns `true` if any pattern matches and `false` otherwise.\n* `set.match(str)` returns an array of indexes of matching patterns.\n  * This is an array of integer indices of patterns that matched sorted in ascending order.\n  * If no patterns matched, an empty array is returned.\n* Read-only properties:\n  * `set.size` (number of patterns), `set.flags` (`RegExp` flags as a string), `set.anchor` (anchor mode as a string)\n  * `set.source` (all patterns joined with `|` as a string), `set.sources` (individual pattern sources as an array of strings)\n  * `set.maxMem` (number) &mdash; effective DFA memory budget in bytes\n\nIt is based on [RE2::Set](https://github.com/google/re2/blob/main/re2/set.h).\n\nExample:\n\n```js\nconst routes = new RE2.Set([\n  '^/users/\\\\d+$',\n  '^/posts/\\\\d+$'\n], 'i', {anchor: 'start'});\n\nroutes.test('/users/7');     // true\nroutes.match('/posts/42');   // [1]\nroutes.sources;              // ['^/users/\\\\d+$', '^/posts/\\\\d+$']\nroutes.toString();           // '/^/users/\\\\d+$|^/posts/\\\\d+$/iu'\n```\n\nTo run the bundled benchmark (make sure node-re2 is built first):\n\n```bash\nnpx nano-bench bench/set-match.mjs\n```\n\n### Calculate length\n\nTwo helpers convert between UTF-8 and UTF-16 sizes:\n\n* `RE2.getUtf8Length(str)` &mdash; byte size needed to encode a string as a UTF-8 buffer.\n* `RE2.getUtf16Length(buf)` &mdash; character count needed to decode a UTF-8 buffer as a string.\n\n### Property: `internalSource`\n\n`source` emulates the standard `RegExp` property and can recreate an identical `RE2` or `RegExp` instance. To inspect the RE2-translated pattern (useful for debugging), use the read-only `internalSource` property.\n\n### Unicode warning level\n\n`RE2` always works in Unicode mode. In most cases this is either invisible or preferred. For applications that need tight control, the static property `RE2.unicodeWarningLevel` governs what happens when a non-Unicode regular expression is created.\n\nIf a regular expression lacks the `u` flag, it is added silently by default:\n\n```js\nconst x = /./;\nx.flags; // ''\nconst y = new RE2(x);\ny.flags; // 'u'\n```\n\nValues of `RE2.unicodeWarningLevel`:\n\n* `'nothing'` (default) &mdash; silently add `u`.\n* `'warnOnce'` &mdash; warn once, then silently add `u`. Assigning this value resets the one-time flag.\n* `'warn'` &mdash; warn every time, still add `u`.\n* `'throw'` &mdash; throw `SyntaxError`.\n* Any other value is silently ignored, leaving the previous value unchanged.\n\nWarnings and exceptions help audit an application for stray non-Unicode regular expressions.\n\n`RE2.unicodeWarningLevel` is global. Be careful in multi-threaded environments &mdash; it is shared across threads.\n\n## How to install\n\n```bash\nnpm install re2\n```\n\nThe project works with other package managers but is not tested with them.\nSee the wiki for notes on [yarn](https://github.com/uhop/node-re2/wiki/Using-with-yarn) and [pnpm](https://github.com/uhop/node-re2/wiki/Using-with-pnpm).\n\n### Supported Node.js versions\n\n`re2` supports every non-EOL Node.js release &mdash; current and active LTS lines. As a native (`nan`) addon it runs on Node.js only, not Bun or Deno. The authoritative supported range is the `engines` field in `package.json`; it also pins the minimum patch releases the build toolchain ([`node-gyp`](https://github.com/nodejs/node-gyp) 13) requires. Check `engines` for the exact floor rather than a version repeated here.\n\n### Install scripts (npm 12+)\n\n`re2` downloads or builds its native binary in an `install` script. Starting with npm 12\n(July 2026), npm does not run dependency install scripts unless the package is listed in the\n`allowScripts` field of your project's `package.json` &mdash; without it, `npm install re2`\nfails with `ESTRICTALLOWSCRIPTS`. npm 11.16+ still runs the scripts but prints a warning.\n\nAllow `re2` before installing:\n\n```bash\nnpm pkg set allowScripts.re2=true --json\nnpm install re2\n```\n\nOr use npm's approval tooling &mdash; note that `npm approve-scripts` only matches installed\npackages, so under npm 12 the package has to be installed with scripts skipped first:\n\n```bash\nnpm install re2 --ignore-scripts\nnpm approve-scripts re2\nnpm rebuild re2\n```\n\n`npm approve-scripts` pins the approval to the installed version, so version updates ask again;\npass `--no-allow-scripts-pin` (or use the `allowScripts.re2=true` form above) to allow all\nversions. No other package in `re2`'s dependency tree runs install scripts. For the full story see\n[NPM 12 and install scripts](https://github.com/uhop/install-artifact-from-github/wiki/NPM-12-and-install-scripts)\nand GitHub's official [announcement of the npm v12 breaking changes](https://github.blog/changelog/2026-06-09-upcoming-breaking-changes-for-npm-v12/).\n\n### Precompiled artifacts\n\nThe [install script](https://github.com/uhop/install-artifact-from-github/blob/master/bin/install-from-cache.js) attempts to download a prebuilt artifact from GitHub Releases. A download from GitHub is [verified](https://github.com/uhop/install-artifact-from-github/wiki/Verifying-artifacts) against the SHA-256 hashes pinned in this package's `artifactHashes` field before it is used &mdash; a binary that is not byte-for-byte the one published is rejected. Override the download location with the `RE2_DOWNLOAD_MIRROR` environment variable (a mirror serves your own builds and is not hash-checked). To skip the download entirely and always build from source, set `RE2_DOWNLOAD_FORCE_BUILD` to a non-empty value.\n\nIf the download fails or is rejected, the script builds RE2 locally using [node-gyp](https://github.com/nodejs/node-gyp).\n\nInstalling from git instead of npm (e.g. `npm install uhop/node-re2#X.Y.Z`; opt-in via `--allow-git` under npm 12) always builds from source: `artifactHashes` is stamped into `package.json` at publish time, so a checkout has no hashes for its own release's binaries and the download is rejected. The npm package is the verified artifact.\n\n## How to use\n\nIt is used just like `RegExp`.\n\n```js\nconst RE2 = require('re2');\n\n// with default flags\nlet re = new RE2('a(b*)');\nlet result = re.exec('abbc');\nconsole.log(result[0]); // 'abb'\nconsole.log(result[1]); // 'bb'\n\nresult = re.exec('aBbC');\nconsole.log(result[0]); // 'a'\nconsole.log(result[1]); // ''\n\n// with explicit flags\nre = new RE2('a(b*)', 'i');\nresult = re.exec('aBbC');\nconsole.log(result[0]); // 'aBb'\nconsole.log(result[1]); // 'Bb'\n\n// from regular expression object\nconst regexp = new RegExp('a(b*)', 'i');\nre = new RE2(regexp);\nresult = re.exec('aBbC');\nconsole.log(result[0]); // 'aBb'\nconsole.log(result[1]); // 'Bb'\n\n// from regular expression literal\nre = new RE2(/a(b*)/i);\nresult = re.exec('aBbC');\nconsole.log(result[0]); // 'aBb'\nconsole.log(result[1]); // 'Bb'\n\n// from another RE2 object\nconst rex = new RE2(re);\nresult = rex.exec('aBbC');\nconsole.log(result[0]); // 'aBb'\nconsole.log(result[1]); // 'Bb'\n\n// shortcut\nresult = new RE2('ab*').exec('abba');\n\n// factory\nresult = RE2('ab*').exec('abba');\n```\n\n## Limitations (things RE2 does not support)\n\n`RE2` avoids any regular expression features that require worst-case exponential time to evaluate.\nThe most notable missing features are backreferences and lookahead assertions.\nIf your application uses them, you should continue to use `RegExp` &mdash;\nbut since they are fundamentally vulnerable to\n[ReDoS](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS),\nconsider replacing them.\n\n`RE2` throws `SyntaxError` for unsupported features.\nWrap `RE2` declarations in a try-catch to fall back to `RegExp`:\n\n```js\nlet re = /(a)+(b)*/;\ntry {\n  re = new RE2(re);\n  // use RE2 as a drop-in replacement\n} catch (e) {\n  // use the original RegExp\n}\nconst result = re.exec(sample);\n```\n\n`RE2` may also behave differently from the built-in engine in corner cases.\n\n### Backreferences\n\n`RE2` does not support backreferences &mdash; numbered references to previously\nmatched groups (`\\1`, `\\2`, etc.). Example:\n\n```js\n/(cat|dog)\\1/.test(\"catcat\"); // true\n/(cat|dog)\\1/.test(\"dogdog\"); // true\n/(cat|dog)\\1/.test(\"catdog\"); // false\n/(cat|dog)\\1/.test(\"dogcat\"); // false\n```\n\n### Lookahead assertions\n\n`RE2` does not support lookahead assertions, which make a match depend on subsequent contents.\n\n```js\n/abc(?=def)/; // match abc only if it is followed by def\n/abc(?!def)/; // match abc only if it is not followed by def\n```\n\n### Mismatched behavior\n\n`RE2` and the built-in engine may disagree in edge cases. Verify your regular expressions before switching. They should work in the vast majority of cases.\n\nExample:\n\n```js\nconst RE2 = require('re2');\n\nconst pattern = '(?:(a)|(b)|(c))+';\n\nconst built_in = new RegExp(pattern);\nconst re2 = new RE2(pattern);\n\nconst input = 'abc';\n\nconst bi_res = built_in.exec(input);\nconst re2_res = re2.exec(input);\n\nconsole.log('bi_res: ' + bi_res);    // prints: bi_res: abc,,,c\nconsole.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c\n```\n\n### Unicode\n\n`RE2` always works in Unicode mode. See `RE2.unicodeWarningLevel` above for details.\n\n#### Unicode classes `\\p{...}` and `\\P{...}`\n\nnode-re2 follows [MDN's Unicode character class escape reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) &mdash; the same set of property escapes that JavaScript's native `RegExp` accepts with the `u` flag.\n\nSupported categories:\n\n- **General_Category** &mdash; both short names (e.g., `\\p{L}`, `\\p{Lu}`) and long names (e.g., `\\p{Letter}`, `\\p{Uppercase_Letter}`). The `gc=` and `General_Category=` prefixes also work: `\\p{gc=Letter}`, `\\p{General_Category=Letter}`.\n- **Script** &mdash; e.g., `\\p{Script=Latin}`, `\\p{sc=Cyrillic}`. ISO 15924 four-letter codes are accepted as well: `\\p{sc=Latn}`.\n- **Script_Extensions** &mdash; e.g., `\\p{Script_Extensions=Hani}`, `\\p{scx=Latn}`. Matches characters whose Script_Extensions list includes the named script (a superset of `Script=`).\n- **Binary properties** &mdash; the full ECMAScript set of binary properties, including:\n  - `Alphabetic`, `ASCII`, `ASCII_Hex_Digit`, `Hex_Digit`, `White_Space`, `Math`, `Dash`, `Diacritic`, `Quotation_Mark`, `Bidi_Mirrored`, `Bidi_Control`, `Default_Ignorable_Code_Point`\n  - `Lowercase`, `Uppercase`, `Cased`, `Case_Ignorable`, `Changes_When_Lowercased`, `Changes_When_Uppercased`, `Changes_When_Casefolded`, `Changes_When_Casemapped`, `Changes_When_Titlecased`, `Changes_When_NFKC_Casefolded`\n  - `ID_Start`, `ID_Continue`, `XID_Start`, `XID_Continue`, `Pattern_Syntax`, `Pattern_White_Space`\n  - `Emoji`, `Emoji_Presentation`, `Emoji_Modifier`, `Emoji_Modifier_Base`, `Emoji_Component`, `Extended_Pictographic`, `Regional_Indicator`\n  - `Grapheme_Base`, `Grapheme_Extend`, `Extender`, `Variation_Selector`, `Join_Control`, `Logical_Order_Exception`, `Sentence_Terminal`, `Terminal_Punctuation`, `Soft_Dotted`, `Radical`, `Unified_Ideograph`, `Ideographic`, `IDS_Binary_Operator`, `IDS_Trinary_Operator`, `Noncharacter_Code_Point`, `Deprecated`, `Any`, `Assigned`\n\n  Short aliases listed in [PropertyAliases.txt](https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt) are accepted alongside the canonical names: `\\p{Alpha}` ≡ `\\p{Alphabetic}`, `\\p{Hex}` ≡ `\\p{Hex_Digit}`, `\\p{Lower}` ≡ `\\p{Lowercase}`, etc.\n\nThe negated form `\\P{...}` and use inside character classes (`[\\p{L}\\p{Emoji}]`, `[^\\p{ASCII}]`) work for every category.\n\n**Not supported:** *Properties of Strings* (`\\p{Basic_Emoji}`, `\\p{RGI_Emoji}`, etc.). These match multi-codepoint sequences and require the `v` flag, which RE2 does not model.\n\nTables are baked in at build time from Unicode 17.0. To target a newer Unicode version, bump `@unicode/unicode-XX.X.X` in `devDependencies` and run `node scripts/gen-unicode-properties.mjs`.\n\n## Release history\n\n- 1.27.0 *Binary input beyond `Buffer`: typed arrays, `DataView`, `ArrayBuffer`, and `SharedArrayBuffer` (#233). Passing a non-`RE2` native object to the constructor throws a `TypeError` instead of crashing (thx, [theosotr](https://github.com/theosotr)).*\n- 1.26.1 *Security fix (GHSA-j4r3-hg7j-8chg): a `Buffer` subject, pattern, or replacement ending in a truncated multi-byte UTF-8 character no longer reads past the end of the buffer &mdash; for `replace()` and `split()` those stray bytes were copied into the returned `Buffer`. Buffer input only; strings were never affected. Thx, [Ovo](https://github.com/OvOhao).*\n- 1.26.0 *Verified prebuilt downloads. Thx, [ataberk-xyz](https://github.com/ataberk-xyz).*\n- 1.25.2 *Two DoS security fixes: a global `match()` with an empty-matchable pattern (`a*`, `(?:)`, &hellip;) no longer loops forever exhausting memory (GHSA-6hxr-mr5r-9836), and an out-of-range `lastIndex` on a non-ASCII subject no longer reads past the buffer and crashes (GHSA-ff84-5f28-78qj). Both now match the built-in engine. Thx, [ataberk-xyz](https://github.com/ataberk-xyz).*\n- 1.25.1 *Security fix (GHSA-8hcv-x26h-mcgp): a global `replace()` using an output-amplifying template (`$'` or `` $` ``) on very large input could exceed V8's maximum string length and abort the whole process. It now throws a catchable `RangeError`, matching the built-in engine. Thx, [ataberk-xyz](https://github.com/ataberk-xyz).*\n- 1.25.0 *Full Unicode 17.0.0 property classes (Fixes #226). New `maxMem` option for `RE2.Set`. Faster matching on pure-ASCII inputs. Narrowed Node support &mdash; drops Node 25.x and older patch releases.*\n- 1.24.1 *Support for Node 22, 24, 26 + precompiled binaries.*\n- 1.24.0 *Fixed multi-threaded crash in worker threads (#235). Added named import: `import {RE2} from 're2'`. Added CJS test. Updated docs and dependencies.*\n- 1.23.3 *Updated Abseil and dev dependencies.*\n- 1.23.2 *Updated dev dependencies.*\n- 1.23.1 *Updated Abseil and dev dependencies.*\n- 1.23.0 *Updated all dependencies, upgraded tooling. New feature: `RE2.Set` (thx, [Wes](https://github.com/wrmedford)).*\n- 1.22.3 *Technical release: upgraded QEMU emulations to native ARM runners to speed up the build process.*\n- 1.22.2 *Updated all dependencies and the list of pre-compiled targets: Node 20, 22, 24, 25 (thx, [Jiayu Liu](https://github.com/jimexist)).*\n- 1.22.1 *Added support for translation of scripts as Unicode classes.*\n- 1.22.0 *Added support for translation of Unicode classes (thx, [John Livingston](https://github.com/JohnXLivingston)). Added [attestations](https://github.com/uhop/node-re2/attestations).*\n- 1.21.5 *Updated all dependencies and the list of pre-compiled targets. Fixed minor bugs. C++ style fix (thx, [Benjamin Brienen](https://github.com/BenjaminBrienen)). Added Windows 11 ARM build runner (thx, [Kagami Sascha Rosylight](https://github.com/saschanaz)).*\n- 1.21.4 *Fixed a regression reported by [caroline-matsec](https://github.com/caroline-matsec), thx! Added pre-compilation targets for Alpine Linux on ARM. Updated deps.*\n- 1.21.3 *Fixed an empty string regression reported by [Rhys Arkins](https://github.com/rarkins), thx! Updated deps.*\n- 1.21.2 *Fixed another memory regression reported by [matthewvalentine](https://github.com/matthewvalentine), thx! Updated deps. Added more tests and benchmarks.*\n- 1.21.1 *Fixed a memory regression reported by [matthewvalentine](https://github.com/matthewvalentine), thx! Updated deps.*\n- 1.21.0 *Fixed the performance problem reported by [matthewvalentine](https://github.com/matthewvalentine) (thx!). The change improves performance for multiple use cases.*\n- 1.20.12 *Updated deps. Maintenance chores. Fixes for buffer-related bugs: `exec()` index (reported by [matthewvalentine](https://github.com/matthewvalentine), thx) and `match()` index.*\n- 1.20.11 *Updated deps. Added support for Node 22 (thx, [Elton Leong](https://github.com/eltonkl)).*\n- 1.20.10 *Updated deps. Removed files the pack used for development (thx, [Haruaki OTAKE](https://github.com/aaharu)). Added arm64 Linux prebilds (thx, [Christopher M](https://github.com/cmanou)). Fixed non-`npm` `corepack` problem (thx, [Steven](https://github.com/styfle)).*\n- 1.20.9 *Updated deps. Added more `absail-cpp` files that manifested itself on NixOS. Thx, [Laura Hausmann](https://github.com/zotanmew).*\n- 1.20.8 *Updated deps: `install-artifact-from-github`. A default HTTPS agent is used for fetching precompiled artifacts avoiding unnecessary long wait times.*\n- 1.20.7 *Added more `absail-cpp` files that manifested itself on ARM Alpine. Thx, [Laura Hausmann](https://github.com/zotanmew).*\n- 1.20.6 *Updated deps, notably `node-gyp`.*\n- 1.20.5 *Updated deps, added Node 21 and retired Node 16 as pre-compilation targets.*\n- 1.20.4 *Updated deps. Fix: the 2nd argument of the constructor overrides flags. Thx, [gost-serb](https://github.com/gost-serb).*\n- 1.20.3 *Fix: subsequent numbers are incorporated into group if they would form a legal group reference. Thx, [Oleksii Vasyliev](https://github.com/le0pard).*\n- 1.20.2 *Fix: added a missing C++ file, which caused a bug on Alpine Linux. Thx, [rbitanga-manticore](https://github.com/rbitanga-manticore).*\n- 1.20.1 *Fix: files included in the npm package to build the C++ code.*\n- 1.20.0 *Updated RE2. New version uses `abseil-cpp` and required the adaptation work. Thx, [Stefano Rivera](https://github.com/stefanor).*\n\nThe rest can be consulted in the project's wiki [Release history](https://github.com/uhop/node-re2/wiki/Release-history).\n\n## License\n\nBSD-3-Clause\n","publish_time":1778629159469,"_cnpm_publish_time":1778629159469,"dist-tags":{"latest":"1.27.2"}}