Skip to content

Conversation

@slevithan
Copy link
Contributor

@slevithan slevithan commented Jun 11, 2024

There have been multiple requests to escape additional characters, so this makes it clearer that minimal escaping is done, per #30 (comment). It also gives a solution for more involved context-aware escaping that handles numerous edge cases, for situations when developers need to insert an escaped string at an arbitrary position in a regex.

Fixes #30

There have been multiple requests to escape additional characters, so this makes it clearer that minimal escaping is done (per #30 (comment)). It also gives a solution for more involved context-aware escaping that handles numerous edge cases, for situations when developers need to insert an escaped string at an arbitrary position in a regex.
@slevithan
Copy link
Contributor Author

If you would prefer that I take out the link to the regex library (which provides a solution for the numerous edge-case context issues when escaping, and is based on discussion amongst TC39 members about alternative approaches for regex escaping), I would be happy to do so. However, I think it's worth letting people know that such edge cases exist.

escape-string-regexp's lack of support for context-related issues is a reasonable tradeoff in favor of simplicity.

@sindresorhus sindresorhus merged commit 6fe67c0 into sindresorhus:main Jun 14, 2024
@sindresorhus
Copy link
Owner

Nice work on the regex package 👍

@slevithan slevithan deleted the patch-1 branch May 3, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forward slash is not escaped

2 participants