Skip to content

Hyphens in Unicode mode #20

Closed
Closed
@brettz9

Description

@brettz9

With the current behavior of escaping -, there is a problem if used in a Unicode regex.

You can see that:

const esc = require('escape-string-regexp');
new RegExp(esc('-'), 'u');

gives:

Invalid regular expression: /-/: Invalid escape

because this does also:

new RegExp('\\-', 'u');

Would seem to call for a Unicode mode? (The hyphen would still need escaping (and be safe to use) within a character class though.)

I don't know whether you'd want to get into such parsing, but just sharing as it is something I came across.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions