Back to Explore

sindresorhus/escape-string-regexp

GitHub
1 watchersOpen source

Last release: 4/17/2021

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-regexp appears 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

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v5.0.0

    4/17/2021

    v5.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.

    Breaking
  • v4.0.0

    4/23/2020

    v4.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.

    Breaking
  • v3.0.0

    4/7/2020

    v3.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.

    Breaking
  • v2.0.0

    4/17/2019

    This 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