Repository navigation
Helpers
Eugene Lazutkin edited this page Nov 8, 2026
·
1 revision
RE2 adds two static helpers and one property to the RegExp interface.
const RE2 = require('re2');
RE2.getUtf8Length('привет'); // 12
RE2.getUtf16Length(Buffer.from('привет')); // 6
new RE2(/\p{Letter}+/u).internalSource; // '\\pL+'Two helpers convert between UTF-8 and UTF-16 sizes:
-
RE2.getUtf8Length(str)— byte size needed to encode a string as a UTF-8 buffer. -
RE2.getUtf16Length(buf)— character count needed to decode a UTF-8 buffer as a string.
source emulates the standard RegExp property and can recreate an identical RE2 or RegExp instance. To inspect the RE2-translated pattern, which is useful for debugging, use the read-only internalSource property.
Installing
Using
Troubleshooting
- Problem: ABI mismatch in Electron
- Problem: build vs prod environments
- Problem: non-ASCII install path
Developers
Research and notes
- Notes on building alternatives
- Related projects
- FilteredRE2 evaluation
- RE2 lookbehinds fork assessment
- V8 Fast API assessment
- V8 non-backtracking RegExp engine
Project
Repository · README · prebuilds via install-artifact-from-github