Back to Explore

sindresorhus/escape-string-regexp

GitHub
2 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 last documented release update is v5.0.0 on 2021-04-17, with the most recent upstream push recorded on 2025-05-06, suggesting limited ongoing release activity and a likely quiet maintenance posture rather than active feature development today.
  • Apparent update cadence is infrequent (major updates in 2019, 2020, and 2021, and no further versioned updates shown after v5.0.0), so changes since the 2021 release are not evident from the provided update history.

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