sqlite-regex is a SQLite extension that adds fast regular expression functions, distributed via npm as a pre-compiled native addon for Node.js. Version 0.2.4-alpha.1 is current; release cadence is irregular as it's maintained by a single developer. Key differentiator: it wraps the RE2 library for safe and performant regex operations, avoiding ReDoS vulnerabilities, and works as a drop-in extension for better-sqlite3 and node-sqlite3. Only supports macOS (x64/arm64), Windows x64, and Linux x64; other platforms may need manual compilation. ESM-only package.
npm install sqlite-regexNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates loading the sqlite-regex extension into better-sqlite3, then using regex_match and regex_captures functions in SQL queries.
Use import statements or dynamic import() instead of require().
Check supported platforms: darwin-x64, darwin-arm64, win32-x64, linux-x64. For unsupported platforms, compile the extension from source.
Manually install the appropriate platform-specific package (e.g., sqlite-regex-darwin-x64) or set npm config to ignore optional dependencies and build from source.
Review RE2 syntax limitations; use alternative LIKE or GLOB for simple patterns if needed.
Use the callback pattern: db.loadExtension(getLoadablePath(), (err) => { if (err) console.error(err); });Use import { getLoadablePath } from 'sqlite-regex' instead of require('sqlite-regex').Ensure you are using better-sqlite3 or node-sqlite3, which have loadExtension. For node-sqlite3, ensure you've created a Database instance.
Check process.arch and process.platform; only x64 and arm64 for macOS, Windows, Linux are supported. For other platforms, build from source.
Delete node_modules and reinstall with npm install --ignore-scripts=false (ensure scripts run). Or manually install the platform-specific package.