Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape - in a way that’s compatible with Unicode patterns #21

Merged
merged 4 commits into from Apr 7, 2020
Merged

Escape - in a way that’s compatible with Unicode patterns #21

merged 4 commits into from Apr 7, 2020

Conversation

charmander
Copy link
Contributor

Regex using the u flag is stricter about unnecessary escapes, and disallows \- outside of character classes. \x2d means a literal hyphen both inside and outside character classes, both with and without the u flag.

Fixes #20.

Regex using the `u` flag is stricter about unnecessary escapes, and disallows `\-` outside of character classes. `\x2d` means a literal hyphen both inside and outside character classes, both with and without the `u` flag.

Fixes #20.
index.js Outdated Show resolved Hide resolved
@charmander
Copy link
Contributor Author

@sindresorhus That kind of comment?

@sindresorhus
Copy link
Owner

Last, can you add a test that just shows that it now works with u?

@charmander
Copy link
Contributor Author

@sindresorhus Added!

@sindresorhus sindresorhus merged commit 732905d into sindresorhus:master Apr 7, 2020
@charmander charmander deleted the unicode-pattern-hyphen branch April 7, 2020 16:27
charmander added a commit to charmander/escape-string-regexp that referenced this pull request Apr 16, 2020
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.

Hyphens in Unicode mode
2 participants