escape-string-regexp provides a small utility to escape RegExp special characters in a string so it can be safely inserted into a JavaScript regular expression. It’s useful when building dynamic RegExp patterns, with the README noting it does only minimal escaping and that you should place the escaped value at safe positions. The source also notes you can use the native `RegExp.escape()` in modern JavaScript.
Project status
- The GitHub upstream for
sindresorhus/escape-string-regexpappears maintained, with a public major-version history and a most recent upstream push timestamp of 2025-05-06, though the last published version updates shown here are from 2021-04-17 (v5.0.0). - Update cadence looks slow and sparse, based on the available versioned changes: major updates occurred in 2020 (v3.0.0, v4.0.0) and 2021 (v5.0.0), with no newer version entries listed after v5.0.0.
AI summary generated Today
Recent updates
v5.0.0
4/17/2021v5.0.0 converts escape-string-regexp to an ESM-only package and raises the minimum Node.js version to 12. The core escaping logic remains essentially the same, but module export wiring changed from CommonJS to an ESM default export.
Breakingv4.0.0
4/23/2020v4.0.0 changes how the hyphen character (-) is escaped in the generated regular expression string. The release notes warn that this is slightly breaking only if callers depend on the exact previous escape output format.
Breakingv3.0.0
4/7/2020v3.0.0 primarily changes runtime requirements and updates how the hyphen character ('-') is escaped to work correctly with Unicode regex patterns. The public API remains a single exported function that accepts a string, but the exact escaping output for '-' changes.
Breakingv2.0.0
4/17/2019This release updates the library to require Node.js 8 and changes the escaping behavior to also escape the dash character ('-'). It also adds TypeScript type definitions to improve developer experience for TypeScript users.
BreakingFeatures