RepoPilot

What edge cases are covered in the tests, especially around hyphens?

About sindresorhus/escape-string-regexp ยท 2 messages ยท last activity 6/8/2026

Question

What edge cases are covered in the tests, especially around hyphens?

RepoPilot

Unfortunately, the repository index has minimal coverage, and the test files aren't included in the retrieved data. The semantic search for test cases returned no results.

However, based on the README excerpt provided, I can tell you what the library does handle:

Documented Edge Cases: The README mentions that "only the minimal amount of escaping is done" and specifically warns about edge cases where "escaped strings (such as immediately following \0 or \c) can change the meaning of the preceding or following token." This suggests the library focuses on core RegExp special characters rather than context-aware escaping.

What's Escaped (from the example): The usage example shows $ and ? being escaped in the string 'How much $ for a ๐Ÿฆ„?' โ†’ 'How much \\$ for a ๐Ÿฆ„\\?', demonstrating that RegExp metacharacters are handled.

To see the actual test cases including hyphen-specific edge cases, you would need to examine the test file directly in the repository (likely test.js or test.ts). The README suggests consulting the regex package if fully context-aware escaping including character class edge cases (like hyphens in character classes) is needed.

FOLLOW_UPS:

  • What RegExp special characters does this library escape?
  • How does minimal escaping differ from full context-aware escaping?
  • Can escaped strings be safely used in character classes?

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/escape-string-regexp. AI answers can be incomplete or stale โ€” verify before relying on them.