Back to Explore

sindresorhus/escape-string-regexp

GitHub
4 watchersOpen source

Last release:

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 repo shows its last tagged published update as v5.0.0 on 2021-04-17, and the most recent upstream push was 2025-05-06, so maintenance activity appears low, with no recent tagged updates evident.
  • Update cadence looks sparse since 2021, with large gaps between major updates (v2.0.0 in 2019, v3.0.0 and v4.0.0 in 2020, v5.0.0 in 2021), which suggests the project is mostly stable rather than frequently evolving.

AI summary generated

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

Recent updates

  • v5.0.0

    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

    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

    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

    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